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 eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "The Alliance pallet provides a collective for standard-setting industry collaboration."
description = "The Alliance pezpallet provides a collective for standard-setting industry collaboration."
readme = "README.md"
documentation = "https://docs.rs/pezpallet-alliance"
+2 -2
View File
@@ -1,6 +1,6 @@
# Alliance Pallet
# Alliance Pezpallet
The Alliance Pallet provides a collective that curates a list of accounts and URLs, deemed by
The Alliance Pezpallet provides a collective that curates a list of accounts and URLs, deemed by
the voting members to be unscrupulous actors. The Alliance
- provides a set of ethics against bad behavior, and
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Alliance pallet benchmarking.
//! Alliance pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
@@ -24,16 +24,16 @@ use pezsp_runtime::traits::{Bounded, Hash, StaticLookup};
use pezframe_benchmarking::{account, v2::*, BenchmarkError};
use pezframe_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
use pezframe_system::{pezpallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin};
use pezframe_system::{pezpallet_prelude::BlockNumberFor, Pezpallet as System, RawOrigin as SystemOrigin};
use super::{Call as AllianceCall, Pallet as Alliance, *};
use super::{Call as AllianceCall, Pezpallet as Alliance, *};
const SEED: u32 = 0;
const MAX_BYTES: u32 = 1_024;
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
}
fn cid(input: impl AsRef<[u8]>) -> Cid {
+76 -76
View File
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Alliance Pallet
//! # Alliance Pezpallet
//!
//! The Alliance Pallet provides a collective that curates a list of accounts and URLs, deemed by
//! The Alliance Pezpallet provides a collective that curates a list of accounts and URLs, deemed by
//! the voting members to be unscrupulous actors. The Alliance
//!
//! - provides a set of ethics against bad behavior, and
@@ -116,17 +116,17 @@ use pezframe_support::{
};
use scale_info::TypeInfo;
pub use pallet::*;
pub use pezpallet::*;
pub use types::*;
pub use weights::*;
/// The log target of this pallet.
/// The log target of this pezpallet.
pub const LOG_TARGET: &str = "runtime::alliance";
/// Simple index type for proposal counting.
pub type ProposalIndex = u32;
type UrlOf<T, I> = BoundedVec<u8, <T as pallet::Config<I>>::MaxWebsiteUrlLength>;
type UrlOf<T, I> = BoundedVec<u8, <T as pezpallet::Config<I>>::MaxWebsiteUrlLength>;
type BalanceOf<T, I> =
<<T as Config<I>>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
@@ -225,15 +225,15 @@ type UnscrupulousItemOf<T, I> =
type AccountIdLookupOf<T> = <<T as pezframe_system::Config>::Lookup as StaticLookup>::Source;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
#[pallet::storage_version(migration::STORAGE_VERSION)]
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(migration::STORAGE_VERSION)]
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -279,41 +279,41 @@ pub mod pallet {
/// Maximum number of proposals allowed to be active in parallel.
type MaxProposals: Get<ProposalIndex>;
/// The maximum number of Fellows supported by the pallet. Used for weight estimation.
/// The maximum number of Fellows supported by the pezpallet. Used for weight estimation.
///
/// NOTE:
/// + Benchmarks will need to be re-run and weights adjusted if this changes.
/// + This pallet assumes that dependencies keep to the limit without enforcing it.
/// + This pezpallet assumes that dependencies keep to the limit without enforcing it.
type MaxFellows: Get<u32>;
/// The maximum number of Allies supported by the pallet. Used for weight estimation.
/// The maximum number of Allies supported by the pezpallet. Used for weight estimation.
///
/// NOTE:
/// + Benchmarks will need to be re-run and weights adjusted if this changes.
/// + This pallet assumes that dependencies keep to the limit without enforcing it.
/// + This pezpallet assumes that dependencies keep to the limit without enforcing it.
type MaxAllies: Get<u32>;
/// The maximum number of the unscrupulous items supported by the pallet.
#[pallet::constant]
/// The maximum number of the unscrupulous items supported by the pezpallet.
#[pezpallet::constant]
type MaxUnscrupulousItems: Get<u32>;
/// The maximum length of a website URL.
#[pallet::constant]
#[pezpallet::constant]
type MaxWebsiteUrlLength: Get<u32>;
/// The deposit required for submitting candidacy.
#[pallet::constant]
#[pezpallet::constant]
type AllyDeposit: Get<BalanceOf<Self, I>>;
/// The maximum number of announcements.
#[pallet::constant]
#[pezpallet::constant]
type MaxAnnouncementsCount: Get<u32>;
/// The maximum number of members per member role.
#[pallet::constant]
#[pezpallet::constant]
type MaxMembersCount: Get<u32>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// The number of blocks a member must wait between giving a retirement notice and retiring.
@@ -321,7 +321,7 @@ pub mod pallet {
type RetirementPeriod: Get<BlockNumberFor<Self>>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// The Alliance has not been initialized yet, therefore accounts cannot join it.
AllianceNotYetInitialized,
@@ -374,8 +374,8 @@ pub mod pallet {
FellowsMissing,
}
#[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<I>, I: 'static = ()> {
/// A new rule has been set.
NewRuleSet { rule: Cid },
@@ -409,7 +409,7 @@ pub mod pallet {
FellowAbdicated { fellow: T::AccountId },
}
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
pub fellows: Vec<T::AccountId>,
@@ -418,24 +418,24 @@ pub mod pallet {
pub phantom: PhantomData<(T, I)>,
}
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
#[cfg(feature = "try-runtime")]
fn try_state(_n: BlockNumberFor<T>) -> Result<(), pezsp_runtime::TryRuntimeError> {
Self::do_try_state()
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
for m in self.fellows.iter().chain(self.allies.iter()) {
assert!(Pallet::<T, I>::has_identity(m).is_ok(), "Member does not set identity!");
assert!(Pezpallet::<T, I>::has_identity(m).is_ok(), "Member does not set identity!");
}
if !self.fellows.is_empty() {
assert!(
!Pallet::<T, I>::has_member(MemberRole::Fellow),
!Pezpallet::<T, I>::has_member(MemberRole::Fellow),
"Fellows are already initialized!"
);
let members: BoundedVec<T::AccountId, T::MaxMembersCount> =
@@ -444,7 +444,7 @@ pub mod pallet {
}
if !self.allies.is_empty() {
assert!(
!Pallet::<T, I>::has_member(MemberRole::Ally),
!Pezpallet::<T, I>::has_member(MemberRole::Ally),
"Allies are already initialized!"
);
assert!(
@@ -462,21 +462,21 @@ pub mod pallet {
/// The IPFS CID of the alliance rule.
/// Fellows can propose a new rule with a super-majority.
#[pallet::storage]
#[pezpallet::storage]
pub type Rule<T: Config<I>, I: 'static = ()> = StorageValue<_, Cid, OptionQuery>;
/// The current IPFS CIDs of any announcements.
#[pallet::storage]
#[pezpallet::storage]
pub type Announcements<T: Config<I>, I: 'static = ()> =
StorageValue<_, BoundedVec<Cid, T::MaxAnnouncementsCount>, ValueQuery>;
/// Maps members to their candidacy deposit.
#[pallet::storage]
#[pezpallet::storage]
pub type DepositOf<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, T::AccountId, BalanceOf<T, I>, OptionQuery>;
/// Maps member type to members of each type.
#[pallet::storage]
#[pezpallet::storage]
pub type Members<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Twox64Concat,
@@ -487,37 +487,37 @@ pub mod pallet {
/// A set of members who gave a retirement notice. They can retire after the end of retirement
/// period stored as a future block number.
#[pallet::storage]
#[pezpallet::storage]
pub type RetiringMembers<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor<T>, OptionQuery>;
/// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit
/// candidacy.
#[pallet::storage]
#[pezpallet::storage]
pub type UnscrupulousAccounts<T: Config<I>, I: 'static = ()> =
StorageValue<_, BoundedVec<T::AccountId, T::MaxUnscrupulousItems>, ValueQuery>;
/// The current list of websites deemed unscrupulous.
#[pallet::storage]
#[pezpallet::storage]
pub type UnscrupulousWebsites<T: Config<I>, I: 'static = ()> =
StorageValue<_, BoundedVec<UrlOf<T, I>, T::MaxUnscrupulousItems>, ValueQuery>;
#[pallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Add a new proposal to be voted on.
///
/// Must be called by a Fellow.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::propose_proposed(
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::propose_proposed(
*length_bound, // B
T::MaxFellows::get(), // M
T::MaxProposals::get(), // P2
))]
pub fn propose(
origin: OriginFor<T>,
#[pallet::compact] threshold: u32,
#[pezpallet::compact] threshold: u32,
proposal: Box<<T as Config<I>>::Proposal>,
#[pallet::compact] length_bound: u32,
#[pezpallet::compact] length_bound: u32,
) -> DispatchResult {
let proposer = ensure_signed(origin)?;
ensure!(Self::has_voting_rights(&proposer), Error::<T, I>::NoVotingRights);
@@ -529,12 +529,12 @@ pub mod pallet {
/// Add an aye or nay vote for the sender to the given proposal.
///
/// Must be called by a Fellow.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::vote(T::MaxFellows::get()))]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::vote(T::MaxFellows::get()))]
pub fn vote(
origin: OriginFor<T>,
proposal: T::Hash,
#[pallet::compact] index: ProposalIndex,
#[pezpallet::compact] index: ProposalIndex,
approve: bool,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -551,8 +551,8 @@ pub mod pallet {
/// The Alliance must be empty, and the call must provide some founding members.
///
/// Must be called by the Root origin.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::init_members(
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::init_members(
fellows.len() as u32,
allies.len() as u32,
))]
@@ -602,8 +602,8 @@ pub mod pallet {
/// Disband the Alliance, remove all active members and unreserve deposits.
///
/// Witness data must be set.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::disband(
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::disband(
witness.fellow_members,
witness.ally_members,
witness.fellow_members.saturating_add(witness.ally_members),
@@ -653,7 +653,7 @@ pub mod pallet {
}
/// Set a new IPFS CID to the alliance rule.
#[pallet::call_index(5)]
#[pezpallet::call_index(5)]
pub fn set_rule(origin: OriginFor<T>, rule: Cid) -> DispatchResult {
T::AdminOrigin::ensure_origin(origin)?;
@@ -664,7 +664,7 @@ pub mod pallet {
}
/// Make an announcement of a new IPFS CID about alliance issues.
#[pallet::call_index(6)]
#[pezpallet::call_index(6)]
pub fn announce(origin: OriginFor<T>, announcement: Cid) -> DispatchResult {
T::AnnouncementOrigin::ensure_origin(origin)?;
@@ -679,7 +679,7 @@ pub mod pallet {
}
/// Remove an announcement.
#[pallet::call_index(7)]
#[pezpallet::call_index(7)]
pub fn remove_announcement(origin: OriginFor<T>, announcement: Cid) -> DispatchResult {
T::AnnouncementOrigin::ensure_origin(origin)?;
@@ -696,7 +696,7 @@ pub mod pallet {
}
/// Submit oneself for candidacy. A fixed deposit is reserved.
#[pallet::call_index(8)]
#[pezpallet::call_index(8)]
pub fn join_alliance(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -732,7 +732,7 @@ pub mod pallet {
/// A Fellow can nominate someone to join the alliance as an Ally. There is no deposit
/// required from the nominator or nominee.
#[pallet::call_index(9)]
#[pezpallet::call_index(9)]
pub fn nominate_ally(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
let nominator = ensure_signed(origin)?;
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
@@ -756,7 +756,7 @@ pub mod pallet {
}
/// Elevate an Ally to Fellow.
#[pallet::call_index(10)]
#[pezpallet::call_index(10)]
pub fn elevate_ally(origin: OriginFor<T>, ally: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let ally = T::Lookup::lookup(ally)?;
@@ -772,7 +772,7 @@ pub mod pallet {
/// As a member, give a retirement notice and start a retirement period required to pass in
/// order to retire.
#[pallet::call_index(11)]
#[pezpallet::call_index(11)]
pub fn give_retirement_notice(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let role = Self::member_role_of(&who).ok_or(Error::<T, I>::NotMember)?;
@@ -782,7 +782,7 @@ pub mod pallet {
Self::add_member(&who, MemberRole::Retiring)?;
<RetiringMembers<T, I>>::insert(
&who,
pezframe_system::Pallet::<T>::block_number()
pezframe_system::Pezpallet::<T>::block_number()
.saturating_add(T::RetirementPeriod::get()),
);
@@ -794,13 +794,13 @@ pub mod pallet {
///
/// This can only be done once you have called `give_retirement_notice` and the
/// `RetirementPeriod` has passed.
#[pallet::call_index(12)]
#[pezpallet::call_index(12)]
pub fn retire(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let retirement_period_end = RetiringMembers::<T, I>::get(&who)
.ok_or(Error::<T, I>::RetirementNoticeNotGiven)?;
ensure!(
pezframe_system::Pallet::<T>::block_number() >= retirement_period_end,
pezframe_system::Pezpallet::<T>::block_number() >= retirement_period_end,
Error::<T, I>::RetirementPeriodNotPassed
);
@@ -816,7 +816,7 @@ pub mod pallet {
}
/// Kick a member from the Alliance and slash its deposit.
#[pallet::call_index(13)]
#[pezpallet::call_index(13)]
pub fn kick_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let member = T::Lookup::lookup(who)?;
@@ -833,8 +833,8 @@ pub mod pallet {
}
/// Add accounts or websites to the list of unscrupulous items.
#[pallet::call_index(14)]
#[pallet::weight(T::WeightInfo::add_unscrupulous_items(items.len() as u32, T::MaxWebsiteUrlLength::get()))]
#[pezpallet::call_index(14)]
#[pezpallet::weight(T::WeightInfo::add_unscrupulous_items(items.len() as u32, T::MaxWebsiteUrlLength::get()))]
pub fn add_unscrupulous_items(
origin: OriginFor<T>,
items: Vec<UnscrupulousItemOf<T, I>>,
@@ -863,8 +863,8 @@ pub mod pallet {
}
/// Deem some items no longer unscrupulous.
#[pallet::call_index(15)]
#[pallet::weight(<T as Config<I>>::WeightInfo::remove_unscrupulous_items(
#[pezpallet::call_index(15)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::remove_unscrupulous_items(
items.len() as u32, T::MaxWebsiteUrlLength::get()
))]
pub fn remove_unscrupulous_items(
@@ -889,8 +889,8 @@ pub mod pallet {
/// Close a vote that is either approved, disapproved, or whose voting period has ended.
///
/// Must be called by a Fellow.
#[pallet::call_index(16)]
#[pallet::weight({
#[pezpallet::call_index(16)]
#[pezpallet::weight({
let b = *length_bound;
let m = T::MaxFellows::get();
let p1 = *proposal_weight_bound;
@@ -904,9 +904,9 @@ pub mod pallet {
pub fn close(
origin: OriginFor<T>,
proposal_hash: T::Hash,
#[pallet::compact] index: ProposalIndex,
#[pezpallet::compact] index: ProposalIndex,
proposal_weight_bound: Weight,
#[pallet::compact] length_bound: u32,
#[pezpallet::compact] length_bound: u32,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
ensure!(Self::has_voting_rights(&who), Error::<T, I>::NoVotingRights);
@@ -917,7 +917,7 @@ pub mod pallet {
/// Abdicate one's position as a voting member and just be an Ally. May be used by Fellows
/// who do not want to leave the Alliance but do not have the capacity to participate
/// operationally for some time.
#[pallet::call_index(17)]
#[pezpallet::call_index(17)]
pub fn abdicate_fellow_status(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let role = Self::member_role_of(&who).ok_or(Error::<T, I>::NotMember)?;
@@ -933,7 +933,7 @@ pub mod pallet {
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Check if the Alliance has been initialized.
fn is_initialized() -> bool {
Self::has_member(MemberRole::Fellow) || Self::has_member(MemberRole::Ally)
@@ -1133,10 +1133,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
#[cfg(any(feature = "try-runtime", test))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Ensure the correctness of the state of this pallet.
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Ensure the correctness of the state of this pezpallet.
///
/// This should be valid before or after each state transition of this pallet.
/// This should be valid before or after each state transition of this pezpallet.
pub fn do_try_state() -> Result<(), pezsp_runtime::TryRuntimeError> {
Self::try_state_members_are_disjoint()?;
Self::try_state_members_are_sorted()?;
@@ -15,16 +15,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{Config, Pallet, Weight, LOG_TARGET};
use crate::{Config, Pezpallet, Weight, LOG_TARGET};
use pezframe_support::{pezpallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade};
use log;
/// The in-code storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
/// Wrapper for all migrations of this pallet.
/// Wrapper for all migrations of this pezpallet.
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
let on_chain_version = Pallet::<T, I>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T, I>::on_chain_storage_version();
let mut weight: Weight = Weight::zero();
if on_chain_version < 1 {
@@ -35,7 +35,7 @@ pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
weight = weight.saturating_add(v1_to_v2::migrate::<T, I>());
}
STORAGE_VERSION.put::<Pallet<T, I>>();
STORAGE_VERSION.put::<Pezpallet<T, I>>();
weight = weight.saturating_add(T::DbWeight::get().writes(1));
weight
@@ -58,7 +58,7 @@ mod v0_to_v1 {
log::info!(target: LOG_TARGET, "Running migration v0_to_v1.");
let res = migration::clear_storage_prefix(
<Pallet<T, I>>::name().as_bytes(),
<Pezpallet<T, I>>::name().as_bytes(),
b"UpForKicking",
b"",
None,
@@ -154,7 +154,7 @@ pub(crate) mod v1_to_v2 {
MemberRoleV1,
BoundedVec<T::AccountId, T::MaxMembersCount>,
Twox64Concat,
>(<Pallet<T, I>>::name().as_bytes(), b"Members", role)
>(<Pezpallet<T, I>>::name().as_bytes(), b"Members", role)
.unwrap_or_default()
}
}
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for the alliance pallet.
//! Tests for the alliance pezpallet.
use pezframe_support::{assert_noop, assert_ok};
use pezframe_system::{EventRecord, Phase};
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_alliance
// --pezpallet=pezpallet_alliance
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/alliance/src/weights.rs
// --wasm-execution=compiled
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME asset conversion pallet"
description = "FRAME asset conversion pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-asset-conversion"
@@ -1,13 +1,13 @@
# asset-conversion
## A swap pallet
## A swap pezpallet
This pallet allows assets to be converted from one type to another by means of a constant product formula.
The pallet based is based on [Uniswap V2](https://github.com/Uniswap/v2-core) logic.
This pezpallet allows assets to be converted from one type to another by means of a constant product formula.
The pezpallet based is based on [Uniswap V2](https://github.com/Uniswap/v2-core) logic.
### Overview
This pallet allows you to:
This pezpallet allows you to:
- create a liquidity pool for 2 assets
- provide the liquidity and receive back an LP token
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME asset conversion pallet's operations suite"
description = "FRAME asset conversion pezpallet's operations suite"
documentation = "https://docs.rs/pezpallet-asset-conversion-ops"
[lints]
@@ -15,17 +15,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Asset Conversion Ops pallet benchmarking.
//! Asset Conversion Ops pezpallet benchmarking.
use super::*;
use crate::Pallet as AssetConversionOps;
use crate::Pezpallet as AssetConversionOps;
use pezframe_benchmarking::{v2::*, whitelisted_caller};
use pezframe_support::{
assert_ok,
traits::fungibles::{Create, Inspect, Mutate},
};
use pezframe_system::RawOrigin as SystemOrigin;
use pezpallet_asset_conversion::{BenchmarkHelper, Pallet as AssetConversion};
use pezpallet_asset_conversion::{BenchmarkHelper, Pezpallet as AssetConversion};
use pezsp_core::Get;
use pezsp_runtime::traits::One;
@@ -122,7 +122,7 @@ where
}
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -17,9 +17,9 @@
//! # Asset Conversion Operations Suite.
//!
//! This pallet provides operational functionalities for the Asset Conversion pallet,
//! This pezpallet provides operational functionalities for the Asset Conversion pezpallet,
//! allowing you to perform various migration and one-time-use operations. These operations
//! are designed to facilitate updates and changes to the Asset Conversion pallet without
//! are designed to facilitate updates and changes to the Asset Conversion pezpallet without
//! breaking its API.
//!
//! ## Overview
@@ -39,7 +39,7 @@ mod mock;
#[cfg(test)]
mod tests;
pub mod weights;
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
extern crate alloc;
@@ -54,16 +54,16 @@ use pezframe_support::traits::{
use pezpallet_asset_conversion::{PoolLocator, Pools};
use pezsp_runtime::traits::{TryConvert, Zero};
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config:
pezpallet_asset_conversion::Config<
PoolId = (
@@ -109,13 +109,13 @@ pub mod pallet {
/// [`pezpallet_asset_conversion::Config::PoolAssets`] registries.
type DepositAsset: FungibleMutate<Self::AccountId>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
}
// Pallet's events.
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
// Pezpallet's events.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Indicates that a pool has been migrated to the new account ID.
MigratedToNewAccount {
@@ -128,7 +128,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Provided asset pair is not supported for pool.
InvalidAssetPair,
@@ -140,15 +140,15 @@ pub mod pallet {
PartialTransfer,
}
/// Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Pezpallet's callable functions.
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Migrates an existing pool to a new account ID derivation method for a given asset pair.
/// If the migration is successful, transaction fees are refunded to the caller.
///
/// Must be signed.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::migrate_to_new_account())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config>::WeightInfo::migrate_to_new_account())]
pub fn migrate_to_new_account(
origin: OriginFor<T>,
asset1: Box<T::AssetKind>,
@@ -301,7 +301,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Returns the prior and new account IDs for a given pool ID. The prior account ID comes
/// first in the tuple.
#[cfg(not(any(test, feature = "runtime-benchmarks")))]
@@ -320,7 +320,7 @@ pub mod pallet {
///
/// This function is intended for use only in test and benchmark environments. The prior
/// account ID represents the new account ID from [`Config::PoolLocator`], allowing the use
/// of the main pallet's calls to set up a pool with liquidity placed in that account and
/// of the main pezpallet's calls to set up a pool with liquidity placed in that account and
/// migrate it to another account, which in this case is the result of
/// [`Config::PriorAccountIdConverter`].
#[cfg(any(test, feature = "runtime-benchmarks"))]
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test environment for Asset Conversion Ops pallet.
//! Test environment for Asset Conversion Ops pezpallet.
use crate as pezpallet_asset_conversion_ops;
use core::default::Default;
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Asset Conversion Ops pallet tests.
//! Asset Conversion Ops pezpallet tests.
use crate::{mock::*, *};
use pezframe_support::{
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_asset_conversion_ops
// --pezpallet=pezpallet_asset_conversion_ops
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/asset-conversion/ops/src/weights.rs
// --wasm-execution=compiled
@@ -15,10 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Asset Conversion pallet benchmarking.
//! Asset Conversion pezpallet benchmarking.
use super::*;
use crate::Pallet as AssetConversion;
use crate::Pezpallet as AssetConversion;
use alloc::vec;
use core::marker::PhantomData;
use pezframe_benchmarking::{v2::*, whitelisted_caller};
@@ -167,7 +167,7 @@ where
}
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
+57 -57
View File
@@ -15,21 +15,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Bizinikiwi Asset Conversion pallet
//! # Bizinikiwi Asset Conversion pezpallet
//!
//! Bizinikiwi Asset Conversion pallet based on the [Uniswap V2](https://github.com/Uniswap/v2-core) logic.
//! Bizinikiwi Asset Conversion pezpallet based on the [Uniswap V2](https://github.com/Uniswap/v2-core) logic.
//!
//! ## Overview
//!
//! This pallet allows you to:
//! This pezpallet allows you to:
//!
//! - [create a liquidity pool](`Pallet::create_pool()`) for 2 assets
//! - [provide the liquidity](`Pallet::add_liquidity()`) and receive back an LP token
//! - [exchange the LP token back to assets](`Pallet::remove_liquidity()`)
//! - [swap a specific amount of assets for another](`Pallet::swap_exact_tokens_for_tokens()`) if
//! - [create a liquidity pool](`Pezpallet::create_pool()`) for 2 assets
//! - [provide the liquidity](`Pezpallet::add_liquidity()`) and receive back an LP token
//! - [exchange the LP token back to assets](`Pezpallet::remove_liquidity()`)
//! - [swap a specific amount of assets for another](`Pezpallet::swap_exact_tokens_for_tokens()`) if
//! there is a pool created, or
//! - [swap some assets for a specific amount of
//! another](`Pallet::swap_tokens_for_exact_tokens()`).
//! another](`Pezpallet::swap_tokens_for_exact_tokens()`).
//! - [query for an exchange price](`AssetConversionApi::quote_price_exact_tokens_for_tokens`) via
//! a runtime call endpoint
//! - [query the size of a liquidity pool](`AssetConversionApi::get_reserves`) via a runtime api
@@ -40,7 +40,7 @@
//! non-native asset 1, you would pass in a path of `[HEZ, 1]` or `[1, HEZ]`. If you want to swap
//! from non-native asset 1 to non-native asset 2, you would pass in a path of `[1, HEZ, 2]`.
//!
//! (For an example of configuring this pallet to use `Location` as an asset id, see the
//! (For an example of configuring this pezpallet to use `Location` as an asset id, see the
//! pezcumulus repo).
//!
//! Here is an example `state_call` that asks for a quote of a pool of native versus asset 1:
@@ -67,7 +67,7 @@ pub mod weights;
#[cfg(feature = "runtime-benchmarks")]
pub use benchmarking::{BenchmarkHelper, NativeOrWithIdFactory};
pub use liquidity::*;
pub use pallet::*;
pub use pezpallet::*;
pub use swap::*;
pub use types::*;
pub use weights::WeightInfo;
@@ -98,17 +98,17 @@ use pezsp_runtime::{
DispatchError, Saturating, TokenError, TransactionOutcome,
};
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::{pezpallet_prelude::*, traits::fungibles::Refund};
use pezframe_system::pezpallet_prelude::*;
use pezsp_arithmetic::{traits::Unsigned, Permill};
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Overarching event type.
#[allow(deprecated)]
@@ -149,7 +149,7 @@ pub mod pallet {
/// Asset class for the lp tokens from [`Self::PoolAssets`].
type PoolAssetId: AssetId + PartialOrd + Incrementable + From<u32>;
/// Registry for the lp tokens. Ideally only this pallet should have create permissions on
/// Registry for the lp tokens. Ideally only this pezpallet should have create permissions on
/// the assets.
type PoolAssets: Inspect<Self::AccountId, AssetId = Self::PoolAssetId, Balance = Self::Balance>
+ Create<Self::AccountId>
@@ -158,37 +158,37 @@ pub mod pallet {
+ Refund<Self::AccountId, AssetId = Self::PoolAssetId>;
/// A % the liquidity providers will take of every swap. Represents 10ths of a percent.
#[pallet::constant]
#[pezpallet::constant]
type LPFee: Get<u32>;
/// A one-time fee to setup the pool.
#[pallet::constant]
#[pezpallet::constant]
type PoolSetupFee: Get<Self::Balance>;
/// Asset class from [`Config::Assets`] used to pay the [`Config::PoolSetupFee`].
#[pallet::constant]
#[pezpallet::constant]
type PoolSetupFeeAsset: Get<Self::AssetKind>;
/// Handler for the [`Config::PoolSetupFee`].
type PoolSetupFeeTarget: OnUnbalanced<CreditOf<Self>>;
/// A fee to withdraw the liquidity.
#[pallet::constant]
#[pezpallet::constant]
type LiquidityWithdrawalFee: Get<Permill>;
/// The minimum LP token amount that could be minted. Ameliorates rounding errors.
#[pallet::constant]
#[pezpallet::constant]
type MintMinLiquidity: Get<Self::Balance>;
/// The max number of hops in a swap.
#[pallet::constant]
#[pezpallet::constant]
type MaxSwapPathLength: Get<u32>;
/// The pallet's id, used for deriving its sovereign account ID.
#[pallet::constant]
/// The pezpallet's id, used for deriving its sovereign account ID.
#[pezpallet::constant]
type PalletId: Get<PalletId>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// The benchmarks need a way to create asset ids from u32s.
@@ -198,18 +198,18 @@ pub mod pallet {
/// Map from `PoolAssetId` to `PoolInfo`. This establishes whether a pool has been officially
/// created rather than people sending tokens directly to a pool's public account.
#[pallet::storage]
#[pezpallet::storage]
pub type Pools<T: Config> =
StorageMap<_, Blake2_128Concat, T::PoolId, PoolInfo<T::PoolAssetId>, OptionQuery>;
/// Stores the `PoolAssetId` that is going to be used for the next lp token.
/// This gets incremented whenever a new lp pool is created.
#[pallet::storage]
#[pezpallet::storage]
pub type NextPoolAssetId<T: Config> = StorageValue<_, T::PoolAssetId, OptionQuery>;
// Pallet's events.
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
// Pezpallet's events.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A successful call of the `CreatePool` extrinsic will create this event.
PoolCreated {
@@ -296,7 +296,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Provided asset pair is not supported for pool.
InvalidAssetPair,
@@ -349,8 +349,8 @@ pub mod pallet {
BelowMinimum,
}
#[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() {
assert!(
T::MaxSwapPathLength::get() > 1,
@@ -359,15 +359,15 @@ pub mod pallet {
}
}
/// Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Pezpallet's callable functions.
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Creates an empty liquidity pool and an associated new `lp_token` asset
/// (the id of which is returned in the `Event::PoolCreated` event).
///
/// Once a pool is created, someone may [`Pallet::add_liquidity`] to it.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::create_pool())]
/// Once a pool is created, someone may [`Pezpallet::add_liquidity`] to it.
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::create_pool())]
pub fn create_pool(
origin: OriginFor<T>,
asset1: Box<T::AssetKind>,
@@ -386,14 +386,14 @@ pub mod pallet {
/// `mint_to` will be sent the liquidity tokens that represent this share of the pool.
///
/// NOTE: when encountering an incorrect exchange rate and non-withdrawable pool liquidity,
/// batch an atomic call with [`Pallet::add_liquidity`] and
/// [`Pallet::swap_exact_tokens_for_tokens`] or [`Pallet::swap_tokens_for_exact_tokens`]
/// batch an atomic call with [`Pezpallet::add_liquidity`] and
/// [`Pezpallet::swap_exact_tokens_for_tokens`] or [`Pezpallet::swap_tokens_for_exact_tokens`]
/// calls to render the liquidity withdrawable and rectify the exchange rate.
///
/// Once liquidity is added, someone may successfully call
/// [`Pallet::swap_exact_tokens_for_tokens`].
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::add_liquidity())]
/// [`Pezpallet::swap_exact_tokens_for_tokens`].
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::add_liquidity())]
pub fn add_liquidity(
origin: OriginFor<T>,
asset1: Box<T::AssetKind>,
@@ -421,8 +421,8 @@ pub mod pallet {
/// Allows you to remove liquidity by providing the `lp_token_burn` tokens that will be
/// burned in the process. With the usage of `amount1_min_receive`/`amount2_min_receive`
/// it's possible to control the min amount of returned tokens you're happy with.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::remove_liquidity())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::remove_liquidity())]
pub fn remove_liquidity(
origin: OriginFor<T>,
asset1: Box<T::AssetKind>,
@@ -451,8 +451,8 @@ pub mod pallet {
///
/// [`AssetConversionApi::quote_price_exact_tokens_for_tokens`] runtime call can be called
/// for a quote.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::swap_exact_tokens_for_tokens(path.len() as u32))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::swap_exact_tokens_for_tokens(path.len() as u32))]
pub fn swap_exact_tokens_for_tokens(
origin: OriginFor<T>,
path: Vec<Box<T::AssetKind>>,
@@ -479,8 +479,8 @@ pub mod pallet {
///
/// [`AssetConversionApi::quote_price_tokens_for_exact_tokens`] runtime call can be called
/// for a quote.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::swap_tokens_for_exact_tokens(path.len() as u32))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::swap_tokens_for_exact_tokens(path.len() as u32))]
pub fn swap_tokens_for_exact_tokens(
origin: OriginFor<T>,
path: Vec<Box<T::AssetKind>>,
@@ -512,8 +512,8 @@ pub mod pallet {
/// - `asset2`: The asset ID of an existing pool with a pair (asset1, asset2).
///
/// Emits `Touched` event when successful.
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::touch(3))]
#[pezpallet::call_index(5)]
#[pezpallet::weight(T::WeightInfo::touch(3))]
pub fn touch(
origin: OriginFor<T>,
asset1: Box<T::AssetKind>,
@@ -545,7 +545,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Create a new liquidity pool.
///
/// **Warning**: The storage must be rolled back on error.
@@ -1281,8 +1281,8 @@ pub mod pallet {
}
}
#[pallet::view_functions]
impl<T: Config> Pallet<T> {
#[pezpallet::view_functions]
impl<T: Config> Pezpallet<T> {
/// Returns the balance of each asset in the pool.
/// The tuple result is in the order requested (not necessarily the same as pool order).
pub fn get_reserves(
@@ -1368,7 +1368,7 @@ pezsp_api::decl_runtime_apis! {
Balance: pezframe_support::traits::tokens::Balance + MaybeDisplay,
AssetId: Codec,
{
/// Provides a quote for [`Pallet::swap_tokens_for_exact_tokens`].
/// Provides a quote for [`Pezpallet::swap_tokens_for_exact_tokens`].
///
/// Note that the price may have changed by the time the transaction is executed.
/// (Use `amount_in_max` to control slippage.)
@@ -1379,7 +1379,7 @@ pezsp_api::decl_runtime_apis! {
include_fee: bool,
) -> Option<Balance>;
/// Provides a quote for [`Pallet::swap_exact_tokens_for_tokens`].
/// Provides a quote for [`Pezpallet::swap_exact_tokens_for_tokens`].
///
/// Note that the price may have changed by the time the transaction is executed.
/// (Use `amount_out_min` to control slippage.)
@@ -20,7 +20,7 @@
use pezframe_support::{traits::tokens::Balance, transactional};
use pezsp_runtime::DispatchError;
use crate::{Config, Pallet};
use crate::{Config, Pezpallet};
/// A struct to represent an asset and its desired and minimum amounts for adding liquidity.
pub struct AddLiquidityAsset<AssetKind, Balance> {
@@ -82,7 +82,7 @@ pub trait MutateLiquidity<AccountId> {
) -> Result<(Self::Balance, Self::Balance), DispatchError>;
}
impl<T: Config> MutateLiquidity<T::AccountId> for Pallet<T> {
impl<T: Config> MutateLiquidity<T::AccountId> for Pezpallet<T> {
type Balance = T::Balance;
type AssetKind = T::AssetKind;
type PoolId = T::PoolId;
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test environment for Asset Conversion pallet.
//! Test environment for Asset Conversion pezpallet.
use super::*;
use crate as pezpallet_asset_conversion;
@@ -144,7 +144,7 @@ pub trait QuotePrice {
) -> Option<Self::Balance>;
}
impl<T: Config> Swap<T::AccountId> for Pallet<T> {
impl<T: Config> Swap<T::AccountId> for Pezpallet<T> {
type Balance = T::Balance;
type AssetKind = T::AssetKind;
@@ -191,7 +191,7 @@ impl<T: Config> Swap<T::AccountId> for Pallet<T> {
}
}
impl<T: Config> SwapCredit<T::AccountId> for Pallet<T> {
impl<T: Config> SwapCredit<T::AccountId> for Pezpallet<T> {
type Balance = T::Balance;
type AssetKind = T::AssetKind;
type Credit = CreditOf<T>;
@@ -239,7 +239,7 @@ impl<T: Config> SwapCredit<T::AccountId> for Pallet<T> {
}
}
impl<T: Config> QuotePrice for Pallet<T> {
impl<T: Config> QuotePrice for Pezpallet<T> {
type Balance = T::Balance;
type AssetKind = T::AssetKind;
fn quote_price_exact_tokens_for_tokens(
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_asset_conversion
// --pezpallet=pezpallet_asset_conversion
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/asset-conversion/src/weights.rs
// --wasm-execution=compiled
@@ -18,7 +18,7 @@
//! The crate's benchmarks.
use super::*;
use crate::{pallet as pezpallet_asset_rate, Pallet as AssetRate};
use crate::{pezpallet as pezpallet_asset_rate, Pezpallet as AssetRate};
use codec::Encode;
use pezframe_benchmarking::v2::*;
+35 -35
View File
@@ -15,14 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Asset Rate Pallet
//! # Asset Rate Pezpallet
//!
//! - [`Config`]
//! - [`Call`]
//!
//! ## Overview
//!
//! The AssetRate pallet provides means of setting conversion rates for some asset to native
//! The AssetRate pezpallet provides means of setting conversion rates for some asset to native
//! balance.
//!
//! The supported dispatchable functions are documented in the [`Call`] enum.
@@ -71,7 +71,7 @@ use pezsp_runtime::{
FixedPointNumber, FixedU128,
};
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
#[cfg(feature = "runtime-benchmarks")]
@@ -86,23 +86,23 @@ pub use benchmarking::AssetKindFactory;
// Type alias for `pezframe_system`'s account id.
type AccountIdOf<T> = <T as pezframe_system::Config>::AccountId;
// This pallet's asset kind and balance type.
// This pezpallet's asset kind and balance type.
type AssetKindOf<T> = <T as Config>::AssetKind;
// Generic fungible balance type.
type BalanceOf<T> = <<T as Config>::Currency as Inspect<AccountIdOf<T>>>::Balance;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The Weight information for extrinsics in this pallet.
/// The Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// The runtime event type.
@@ -118,7 +118,7 @@ pub mod pallet {
/// The origin permissioned to update an existing conversion rate for an asset.
type UpdateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The currency mechanism for this pallet.
/// The currency mechanism for this pezpallet.
type Currency: Inspect<Self::AccountId>;
/// The type for asset kinds for which the conversion rate to native balance is set.
@@ -132,12 +132,12 @@ pub mod pallet {
/// Maps an asset to its fixed point representation in the native balance.
///
/// E.g. `native_amount = asset_amount * ConversionRateToNative::<T>::get(asset_kind)`
#[pallet::storage]
#[pezpallet::storage]
pub type ConversionRateToNative<T: Config> =
StorageMap<_, Blake2_128Concat, T::AssetKind, FixedU128, OptionQuery>;
#[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> {
// Some `asset_kind` conversion rate was created.
AssetRateCreated { asset_kind: T::AssetKind, rate: FixedU128 },
@@ -147,7 +147,7 @@ pub mod pallet {
AssetRateUpdated { asset_kind: T::AssetKind, old: FixedU128, new: FixedU128 },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The given asset ID is unknown.
UnknownAssetKind,
@@ -157,14 +157,14 @@ pub mod pallet {
Overflow,
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Initialize a conversion rate to native balance for the given asset.
///
/// ## Complexity
/// - O(1)
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::create())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::create())]
pub fn create(
origin: OriginFor<T>,
asset_kind: Box<T::AssetKind>,
@@ -186,8 +186,8 @@ pub mod pallet {
///
/// ## Complexity
/// - O(1)
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::update())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::update())]
pub fn update(
origin: OriginFor<T>,
asset_kind: Box<T::AssetKind>,
@@ -219,8 +219,8 @@ pub mod pallet {
///
/// ## Complexity
/// - O(1)
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::remove())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::remove())]
pub fn remove(origin: OriginFor<T>, asset_kind: Box<T::AssetKind>) -> DispatchResult {
T::RemoveOrigin::ensure_origin(origin)?;
@@ -237,45 +237,45 @@ pub mod pallet {
}
/// Exposes conversion of an arbitrary balance of an asset to native balance.
impl<T> ConversionFromAssetBalance<BalanceOf<T>, AssetKindOf<T>, BalanceOf<T>> for Pallet<T>
impl<T> ConversionFromAssetBalance<BalanceOf<T>, AssetKindOf<T>, BalanceOf<T>> for Pezpallet<T>
where
T: Config,
{
type Error = pallet::Error<T>;
type Error = pezpallet::Error<T>;
fn from_asset_balance(
balance: BalanceOf<T>,
asset_kind: AssetKindOf<T>,
) -> Result<BalanceOf<T>, pallet::Error<T>> {
let rate = pallet::ConversionRateToNative::<T>::get(asset_kind)
.ok_or(pallet::Error::<T>::UnknownAssetKind.into())?;
) -> Result<BalanceOf<T>, pezpallet::Error<T>> {
let rate = pezpallet::ConversionRateToNative::<T>::get(asset_kind)
.ok_or(pezpallet::Error::<T>::UnknownAssetKind.into())?;
Ok(rate.saturating_mul_int(balance))
}
/// Set a conversion rate to `1` for the `asset_id`.
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful(asset_id: AssetKindOf<T>) {
pallet::ConversionRateToNative::<T>::set(asset_id.clone(), Some(1.into()));
pezpallet::ConversionRateToNative::<T>::set(asset_id.clone(), Some(1.into()));
}
}
/// Exposes conversion of a native balance to an asset balance.
impl<T> ConversionToAssetBalance<BalanceOf<T>, AssetKindOf<T>, BalanceOf<T>> for Pallet<T>
impl<T> ConversionToAssetBalance<BalanceOf<T>, AssetKindOf<T>, BalanceOf<T>> for Pezpallet<T>
where
T: Config,
{
type Error = pallet::Error<T>;
type Error = pezpallet::Error<T>;
fn to_asset_balance(
balance: BalanceOf<T>,
asset_kind: AssetKindOf<T>,
) -> Result<BalanceOf<T>, pallet::Error<T>> {
let rate = pallet::ConversionRateToNative::<T>::get(asset_kind)
.ok_or(pallet::Error::<T>::UnknownAssetKind.into())?;
) -> Result<BalanceOf<T>, pezpallet::Error<T>> {
let rate = pezpallet::ConversionRateToNative::<T>::get(asset_kind)
.ok_or(pezpallet::Error::<T>::UnknownAssetKind.into())?;
// We cannot use `saturating_div` here so we use `checked_div`.
Ok(FixedU128::from_u32(1)
.checked_div(&rate)
.ok_or(pallet::Error::<T>::Overflow.into())?
.ok_or(pezpallet::Error::<T>::Overflow.into())?
.saturating_mul_int(balance))
}
}
+1 -1
View File
@@ -18,7 +18,7 @@
//! The crate's tests.
use super::*;
use crate::pallet as pezpallet_asset_rate;
use crate::pezpallet as pezpallet_asset_rate;
use pezframe_support::{assert_noop, assert_ok};
use mock::{new_test_ext, AssetRate, RuntimeOrigin, Test};
use pezsp_runtime::FixedU128;
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_asset_rate
// --pezpallet=pezpallet_asset_rate
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/asset-rate/src/weights.rs
// --wasm-execution=compiled
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME asset rewards pallet"
description = "FRAME asset rewards pezpallet"
documentation = "https://docs.rs/pezpallet-asset-rewards"
[lints]
@@ -15,10 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Asset Rewards pallet benchmarking.
//! Asset Rewards pezpallet benchmarking.
use super::*;
use crate::Pallet as AssetRewards;
use crate::Pezpallet as AssetRewards;
use pezframe_benchmarking::{v2::*, whitelisted_caller, BenchmarkError};
use pezframe_support::{
assert_ok,
@@ -27,7 +27,7 @@ use pezframe_support::{
Consideration, EnsureOrigin, Footprint,
},
};
use pezframe_system::{Pallet as System, RawOrigin};
use pezframe_system::{Pezpallet as System, RawOrigin};
use pezsp_runtime::{traits::One, Saturating};
use pezsp_std::prelude::*;
+48 -48
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # FRAME Staking Rewards Pallet
//! # FRAME Staking Rewards Pezpallet
//!
//! Allows accounts to be rewarded for holding `fungible` asset/s, for example LP tokens.
//!
@@ -41,14 +41,14 @@
//!
//! ## Disambiguation
//!
//! While this pallet shares some terminology with the `staking-pool` and similar native staking
//! While this pezpallet shares some terminology with the `staking-pool` and similar native staking
//! related pallets, it is distinct and is entirely unrelated to native staking.
//!
//! ## Permissioning
//!
//! Currently, pool creation and management restricted to a configured Origin.
//!
//! Future iterations of this pallet may allow permissionless creation and management of pools.
//! Future iterations of this pezpallet may allow permissionless creation and management of pools.
//!
//! Note: The permissioned origin must return an AccountId. This can be achieved for any Origin by
//! wrapping it with `EnsureSuccess`.
@@ -59,8 +59,8 @@
//! without side-effects.
//!
//! Storage interaction such as reads and writes are instead all performed in the top level
//! pallet Call method, which while slightly more verbose, makes it easier to understand the
//! code and reason about how storage reads and writes occur in the pallet.
//! pezpallet Call method, which while slightly more verbose, makes it easier to understand the
//! code and reason about how storage reads and writes occur in the pezpallet.
//!
//! ## Rewards Algorithm
//!
@@ -80,7 +80,7 @@
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
pub use pezpallet::*;
use codec::{Codec, Decode, Encode, MaxEncodedLen};
use pezframe_support::{
@@ -125,10 +125,10 @@ pub type PoolInfoFor<T> = PoolInfo<
BlockNumberFor<T>,
>;
/// The block number type for the pallet.
/// The block number type for the pezpallet.
///
/// This type is derived from the `BlockNumberProvider` associated type in the `Config` trait.
/// It represents the block number type that the pallet uses for scheduling and expiration.
/// It represents the block number type that the pezpallet uses for scheduling and expiration.
pub type BlockNumberFor<T> =
<<T as Config>::BlockNumberProvider as BlockNumberProvider>::BlockNumber;
@@ -167,7 +167,7 @@ pub struct PoolInfo<AccountId, AssetId, Balance, BlockNumber> {
}
pezsp_api::decl_runtime_apis! {
/// The runtime API for the asset rewards pallet.
/// The runtime API for the asset rewards pezpallet.
pub trait AssetRewards<Cost: MaybeDisplay + Codec> {
/// Get the cost of creating a pool.
///
@@ -176,8 +176,8 @@ pezsp_api::decl_runtime_apis! {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::{
pezpallet_prelude::*,
@@ -198,35 +198,35 @@ pub mod pallet {
DispatchResult,
};
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// A reason for the pallet placing a hold on funds.
#[pallet::composite_enum]
/// A reason for the pezpallet placing a hold on funds.
#[pezpallet::composite_enum]
pub enum FreezeReason {
/// Funds are staked in the pallet.
/// Funds are staked in the pezpallet.
#[codec(index = 0)]
Staked,
}
/// A reason for the pallet placing a hold on funds.
#[pallet::composite_enum]
/// A reason for the pezpallet placing a hold on funds.
#[pezpallet::composite_enum]
pub enum HoldReason {
/// Cost associated with storing pool information on-chain.
#[codec(index = 0)]
PoolCreation,
}
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The pallet's unique identifier, used to derive the pool's account ID.
/// The pezpallet's unique identifier, used to derive the pool's account ID.
///
/// The account ID is derived once during pool creation and stored in the storage.
#[pallet::constant]
#[pezpallet::constant]
type PalletId: Get<PalletId>;
/// Identifier for each type of asset.
@@ -263,17 +263,17 @@ pub mod pallet {
/// information itself, excluding any potential storage footprint related to the stakers.
type Consideration: Consideration<Self::AccountId, Footprint>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// Provider for the current block number.
///
/// This provider is used to determine the current block number for the pallet.
/// This provider is used to determine the current block number for the pezpallet.
/// It must return monotonically increasing values when called from consecutive blocks.
///
/// It can be configured to use the local block number (via `pezframe_system::Pallet`) or a
/// It can be configured to use the local block number (via `pezframe_system::Pezpallet`) or a
/// remote block number (e.g., from a relay chain). However, note that using a remote
/// block number might have implications for the behavior of the pallet, especially if the
/// block number might have implications for the behavior of the pezpallet, especially if the
/// remote block number advances faster than the local block number.
///
/// It is recommended to use the local block number for solo chains and relay chains.
@@ -285,7 +285,7 @@ pub mod pallet {
}
/// State of pool stakers.
#[pallet::storage]
#[pezpallet::storage]
pub type PoolStakers<T: Config> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -296,25 +296,25 @@ pub mod pallet {
>;
/// State and configuration of each staking pool.
#[pallet::storage]
#[pezpallet::storage]
pub type Pools<T: Config> = StorageMap<_, Blake2_128Concat, PoolId, PoolInfoFor<T>>;
/// The cost associated with storing pool information on-chain which was incurred by the pool
/// creator.
///
/// This cost may be [`None`], as determined by [`Config::Consideration`].
#[pallet::storage]
#[pezpallet::storage]
pub type PoolCost<T: Config> =
StorageMap<_, Blake2_128Concat, PoolId, (T::AccountId, T::Consideration)>;
/// Stores the [`PoolId`] to use for the next pool.
///
/// Incremented when a new pool is created.
#[pallet::storage]
#[pezpallet::storage]
pub type NextPoolId<T: Config> = StorageValue<_, PoolId, ValueQuery>;
#[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> {
/// An account staked some tokens in a pool.
Staked {
@@ -392,7 +392,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The staker does not have enough tokens to perform the operation.
NotEnoughTokens,
@@ -416,8 +416,8 @@ pub mod pallet {
NonEmptyPool,
}
#[pallet::hooks]
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pezpallet<T> {
fn integrity_test() {
// The AccountId is at least 16 bytes to contain the unique PalletId.
let pool_id: PoolId = 1;
@@ -430,9 +430,9 @@ pub mod pallet {
}
}
/// Pallet's callable functions.
#[pallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pallet<T> {
/// Pezpallet's callable functions.
#[pezpallet::call(weight(<T as Config>::WeightInfo))]
impl<T: Config> Pezpallet<T> {
/// Create a new reward pool.
///
/// Parameters:
@@ -445,7 +445,7 @@ pub mod pallet {
/// - `admin`: the account allowed to extend the pool expiration, increase the rewards rate
/// and receive the unutilized reward tokens back after the pool completion. If `None`,
/// the caller is set as an admin.
#[pallet::call_index(0)]
#[pezpallet::call_index(0)]
pub fn create_pool(
origin: OriginFor<T>,
staked_asset_id: Box<T::AssetId>,
@@ -469,7 +469,7 @@ pub mod pallet {
/// Stake additional tokens in a pool.
///
/// A freeze is placed on the staked tokens.
#[pallet::call_index(1)]
#[pezpallet::call_index(1)]
pub fn stake(origin: OriginFor<T>, pool_id: PoolId, amount: T::Balance) -> DispatchResult {
let staker = ensure_signed(origin)?;
@@ -510,7 +510,7 @@ pub mod pallet {
/// - pool_id: the pool to unstake from.
/// - amount: the amount of tokens to unstake.
/// - staker: the account to unstake from. If `None`, the caller is used.
#[pallet::call_index(2)]
#[pezpallet::call_index(2)]
pub fn unstake(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -565,7 +565,7 @@ pub mod pallet {
/// - origin: must be the `staker` if the pool is still active. Otherwise, any account.
/// - pool_id: the pool to harvest from.
/// - staker: the account for which to harvest rewards. If `None`, the caller is used.
#[pallet::call_index(3)]
#[pezpallet::call_index(3)]
pub fn harvest_rewards(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -619,7 +619,7 @@ pub mod pallet {
/// Currently the reward rate can only be increased.
///
/// Only the pool admin may perform this operation.
#[pallet::call_index(4)]
#[pezpallet::call_index(4)]
pub fn set_pool_reward_rate_per_block(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -637,7 +637,7 @@ pub mod pallet {
/// Modify a pool admin.
///
/// Only the pool admin may perform this operation.
#[pallet::call_index(5)]
#[pezpallet::call_index(5)]
pub fn set_pool_admin(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -653,7 +653,7 @@ pub mod pallet {
/// Currently the expiry block can only be extended.
///
/// Only the pool admin may perform this operation.
#[pallet::call_index(6)]
#[pezpallet::call_index(6)]
pub fn set_pool_expiry_block(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -669,7 +669,7 @@ pub mod pallet {
/// This method is not strictly necessary (tokens could be transferred directly to the
/// pool pot address), but is provided for convenience so manual derivation of the
/// account id is not required.
#[pallet::call_index(7)]
#[pezpallet::call_index(7)]
pub fn deposit_reward_tokens(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -693,7 +693,7 @@ pub mod pallet {
///
/// Cleanup storage, release any associated storage cost and return the remaining reward
/// tokens to the admin.
#[pallet::call_index(8)]
#[pezpallet::call_index(8)]
pub fn cleanup_pool(origin: OriginFor<T>, pool_id: PoolId) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -729,7 +729,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// The pool creation footprint.
///
/// The footprint specifically accounts for the storage footprint of the pool's information
@@ -834,7 +834,7 @@ pub mod pallet {
}
}
impl<T: Config> RewardsPool<T::AccountId> for Pallet<T> {
impl<T: Config> RewardsPool<T::AccountId> for Pezpallet<T> {
type AssetId = T::AssetId;
type BlockNumber = BlockNumberFor<T>;
type PoolId = PoolId;
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test environment for Asset Rewards pallet.
//! Test environment for Asset Rewards pezpallet.
use super::*;
use crate as pezpallet_asset_rewards;
@@ -124,7 +124,7 @@ impl EnsureOrigin<RuntimeOrigin> for MockPermissionedOrigin {
}
}
/// Allow Freezes for the `Assets` pallet
/// Allow Freezes for the `Assets` pezpallet
impl pezpallet_assets_freezer::Config<pezpallet_assets_freezer::Instance1> for MockRuntime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type RuntimeEvent = RuntimeEvent;
@@ -168,7 +168,7 @@ impl Config for MockRuntime {
CreationHoldReason,
LinearStoragePrice<ConstU128<100>, ConstU128<0>, u128>,
>;
type BlockNumberProvider = pezframe_system::Pallet<Self>;
type BlockNumberProvider = pezframe_system::Pezpallet<Self>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = AssetRewardsBenchmarkHelper;
}
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_asset_rewards
// --pezpallet=pezpallet_asset_rewards
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/asset-rewards/src/weights.rs
// --wasm-execution=compiled
+13 -13
View File
@@ -26,10 +26,10 @@ use frame::prelude::storage::StorageDoubleMap;
use pezpallet_assets::FrozenBalance;
// Implements [`FrozenBalance`] from [`pezpallet-assets`], so it can understand how much of an
// account balance is frozen, and is able to signal to this pallet when to clear the state of an
// account balance is frozen, and is able to signal to this pezpallet when to clear the state of an
// account.
impl<T: Config<I>, I: 'static> FrozenBalance<T::AssetId, T::AccountId, T::Balance>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn frozen_balance(asset: T::AssetId, who: &T::AccountId) -> Option<T::Balance> {
FrozenBalances::<T, I>::get(asset, who)
@@ -58,24 +58,24 @@ impl<T: Config<I>, I: 'static> FrozenBalance<T::AssetId, T::AccountId, T::Balanc
// [`fungibles::InspectFreeze`](pezframe_support::traits::fungibles::InspectFreeze) and
// [`fungibles::MutateFreeze`](pezframe_support::traits::fungibles::MutateFreeze). To do so, we'll
// re-export all of `pezpallet-assets` implementation of the same trait.
impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pezpallet<T, I> {
type AssetId = T::AssetId;
type Balance = T::Balance;
fn total_issuance(asset: Self::AssetId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::total_issuance(asset)
pezpallet_assets::Pezpallet::<T, I>::total_issuance(asset)
}
fn minimum_balance(asset: Self::AssetId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::minimum_balance(asset)
pezpallet_assets::Pezpallet::<T, I>::minimum_balance(asset)
}
fn total_balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::total_balance(asset, who)
pezpallet_assets::Pezpallet::<T, I>::total_balance(asset, who)
}
fn balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::balance(asset, who)
pezpallet_assets::Pezpallet::<T, I>::balance(asset, who)
}
fn reducible_balance(
@@ -84,7 +84,7 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
preservation: Preservation,
force: Fortitude,
) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::reducible_balance(asset, who, preservation, force)
pezpallet_assets::Pezpallet::<T, I>::reducible_balance(asset, who, preservation, force)
}
fn can_deposit(
@@ -93,7 +93,7 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
amount: Self::Balance,
provenance: Provenance,
) -> DepositConsequence {
pezpallet_assets::Pallet::<T, I>::can_deposit(asset, who, amount, provenance)
pezpallet_assets::Pezpallet::<T, I>::can_deposit(asset, who, amount, provenance)
}
fn can_withdraw(
@@ -101,15 +101,15 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
who: &T::AccountId,
amount: Self::Balance,
) -> WithdrawConsequence<Self::Balance> {
pezpallet_assets::Pallet::<T, I>::can_withdraw(asset, who, amount)
pezpallet_assets::Pezpallet::<T, I>::can_withdraw(asset, who, amount)
}
fn asset_exists(asset: Self::AssetId) -> bool {
pezpallet_assets::Pallet::<T, I>::asset_exists(asset)
pezpallet_assets::Pezpallet::<T, I>::asset_exists(asset)
}
}
impl<T: Config<I>, I: 'static> InspectFreeze<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> InspectFreeze<T::AccountId> for Pezpallet<T, I> {
type Id = T::RuntimeFreezeReason;
fn balance_frozen(asset: Self::AssetId, id: &Self::Id, who: &T::AccountId) -> Self::Balance {
@@ -123,7 +123,7 @@ impl<T: Config<I>, I: 'static> InspectFreeze<T::AccountId> for Pallet<T, I> {
}
}
impl<T: Config<I>, I: 'static> MutateFreeze<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> MutateFreeze<T::AccountId> for Pezpallet<T, I> {
fn set_freeze(
asset: Self::AssetId,
id: &Self::Id,
+22 -22
View File
@@ -21,25 +21,25 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//! # Assets Freezer Pallet
//! # Assets Freezer Pezpallet
//!
//! A pallet capable of freezing fungibles from `pezpallet-assets`. This is an extension of
//! A pezpallet capable of freezing fungibles from `pezpallet-assets`. This is an extension of
//! `pezpallet-assets`, wrapping [`fungibles::Inspect`](`Inspect`).
//! It implements both
//! [`fungibles::freeze::Inspect`](InspectFreeze) and
//! [`fungibles::freeze::Mutate`](MutateFreeze). The complexity
//! of the operations is `O(n)`. where `n` is the variant count of `RuntimeFreezeReason`.
//!
//! ## Pallet API
//! ## Pezpallet API
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes,
//! including its configuration trait, dispatchables, storage items, events and errors.
//!
//! ## Overview
//!
//! This pallet provides the following functionality:
//! This pezpallet provides the following functionality:
//!
//! - Pallet hooks allowing [`pezpallet-assets`] to know the frozen balance for an account on a given
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the frozen balance for an account on a given
//! asset (see [`pezpallet_assets::FrozenBalance`]).
//! - An implementation of [`fungibles::freeze::Inspect`](InspectFreeze) and
//! [`fungibles::freeze::Mutate`](MutateFreeze), allowing other pallets to manage freezes for the
@@ -57,7 +57,7 @@ use frame::{
},
};
pub use pallet::*;
pub use pezpallet::*;
#[cfg(feature = "try-runtime")]
use frame::try_runtime::TryRuntimeError;
@@ -69,34 +69,34 @@ mod tests;
mod impls;
#[frame::pallet]
pub mod pallet {
#[frame::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::config(with_default)]
#[pezpallet::config(with_default)]
pub trait Config<I: 'static = ()>: pezframe_system::Config + pezpallet_assets::Config<I> {
/// The overarching freeze reason.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeFreezeReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount;
/// The overarching event type.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// Number of freezes on an account would exceed `MaxFreezes`.
TooManyFreezes,
}
#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(_);
#[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<I>, I: 'static = ()> {
// `who`s frozen balance was increased by `amount`.
Frozen { who: T::AccountId, asset_id: T::AssetId, amount: T::Balance },
@@ -105,7 +105,7 @@ pub mod pallet {
}
/// A map that stores freezes applied on an account for a given AssetId.
#[pallet::storage]
#[pezpallet::storage]
pub type Freezes<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -120,7 +120,7 @@ pub mod pallet {
>;
/// A map that stores the current total frozen balance for every account on a given AssetId.
#[pallet::storage]
#[pezpallet::storage]
pub type FrozenBalances<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -130,8 +130,8 @@ pub mod pallet {
T::Balance,
>;
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
#[cfg(feature = "try-runtime")]
fn try_state(_: BlockNumberFor<T>) -> Result<(), TryRuntimeError> {
Self::do_try_state()
@@ -139,7 +139,7 @@ pub mod pallet {
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
fn update_freezes(
asset: T::AssetId,
who: &T::AccountId,
@@ -31,10 +31,10 @@ use pezsp_runtime::{
use storage::StorageDoubleMap;
// Implements [`BalanceOnHold`] from [`pezpallet-assets`], so it can understand whether there's some
// balance on hold for an asset account, and is able to signal to this pallet when to clear the
// balance on hold for an asset account, and is able to signal to this pezpallet when to clear the
// state of an account.
impl<T: Config<I>, I: 'static> BalanceOnHold<T::AssetId, T::AccountId, T::Balance>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn balance_on_hold(asset: T::AssetId, who: &T::AccountId) -> Option<T::Balance> {
BalancesOnHold::<T, I>::get(asset, who)
@@ -63,24 +63,24 @@ impl<T: Config<I>, I: 'static> BalanceOnHold<T::AssetId, T::AccountId, T::Balanc
// [`fungibles::InspectHold`](pezframe_support::traits::fungibles::InspectHold) and
// [`fungibles::MutateHold`](pezframe_support::traits::fungibles::MutateHold). To do so, we'll
// re-export all of `pezpallet-assets` implementation of the same trait.
impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pezpallet<T, I> {
type AssetId = T::AssetId;
type Balance = T::Balance;
fn total_issuance(asset: Self::AssetId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::total_issuance(asset)
pezpallet_assets::Pezpallet::<T, I>::total_issuance(asset)
}
fn minimum_balance(asset: Self::AssetId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::minimum_balance(asset)
pezpallet_assets::Pezpallet::<T, I>::minimum_balance(asset)
}
fn total_balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::total_balance(asset, who)
pezpallet_assets::Pezpallet::<T, I>::total_balance(asset, who)
}
fn balance(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::balance(asset, who)
pezpallet_assets::Pezpallet::<T, I>::balance(asset, who)
}
fn reducible_balance(
@@ -89,7 +89,7 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
preservation: Preservation,
force: Fortitude,
) -> Self::Balance {
pezpallet_assets::Pallet::<T, I>::reducible_balance(asset, who, preservation, force)
pezpallet_assets::Pezpallet::<T, I>::reducible_balance(asset, who, preservation, force)
}
fn can_deposit(
@@ -98,7 +98,7 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
amount: Self::Balance,
provenance: Provenance,
) -> DepositConsequence {
pezpallet_assets::Pallet::<T, I>::can_deposit(asset, who, amount, provenance)
pezpallet_assets::Pezpallet::<T, I>::can_deposit(asset, who, amount, provenance)
}
fn can_withdraw(
@@ -106,15 +106,15 @@ impl<T: Config<I>, I: 'static> Inspect<T::AccountId> for Pallet<T, I> {
who: &T::AccountId,
amount: Self::Balance,
) -> WithdrawConsequence<Self::Balance> {
pezpallet_assets::Pallet::<T, I>::can_withdraw(asset, who, amount)
pezpallet_assets::Pezpallet::<T, I>::can_withdraw(asset, who, amount)
}
fn asset_exists(asset: Self::AssetId) -> bool {
pezpallet_assets::Pallet::<T, I>::asset_exists(asset)
pezpallet_assets::Pezpallet::<T, I>::asset_exists(asset)
}
}
impl<T: Config<I>, I: 'static> InspectHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> InspectHold<T::AccountId> for Pezpallet<T, I> {
type Reason = T::RuntimeHoldReason;
fn total_balance_on_hold(asset: Self::AssetId, who: &T::AccountId) -> Self::Balance {
@@ -134,10 +134,10 @@ impl<T: Config<I>, I: 'static> InspectHold<T::AccountId> for Pallet<T, I> {
}
}
impl<T: Config<I>, I: 'static> Unbalanced<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> Unbalanced<T::AccountId> for Pezpallet<T, I> {
fn handle_dust(dust: Dust<T::AccountId, Self>) {
let Dust(id, balance) = dust;
pezpallet_assets::Pallet::<T, I>::handle_dust(Dust(id, balance));
pezpallet_assets::Pezpallet::<T, I>::handle_dust(Dust(id, balance));
}
fn write_balance(
@@ -145,11 +145,11 @@ impl<T: Config<I>, I: 'static> Unbalanced<T::AccountId> for Pallet<T, I> {
who: &T::AccountId,
amount: Self::Balance,
) -> Result<Option<Self::Balance>, DispatchError> {
pezpallet_assets::Pallet::<T, I>::write_balance(asset, who, amount)
pezpallet_assets::Pezpallet::<T, I>::write_balance(asset, who, amount)
}
fn set_total_issuance(asset: Self::AssetId, amount: Self::Balance) {
pezpallet_assets::Pallet::<T, I>::set_total_issuance(asset, amount)
pezpallet_assets::Pezpallet::<T, I>::set_total_issuance(asset, amount)
}
fn decrease_balance(
@@ -160,7 +160,7 @@ impl<T: Config<I>, I: 'static> Unbalanced<T::AccountId> for Pallet<T, I> {
preservation: Preservation,
force: Fortitude,
) -> Result<Self::Balance, DispatchError> {
pezpallet_assets::Pallet::<T, I>::decrease_balance(
pezpallet_assets::Pezpallet::<T, I>::decrease_balance(
asset,
who,
amount,
@@ -176,11 +176,11 @@ impl<T: Config<I>, I: 'static> Unbalanced<T::AccountId> for Pallet<T, I> {
amount: Self::Balance,
precision: Precision,
) -> Result<Self::Balance, DispatchError> {
pezpallet_assets::Pallet::<T, I>::increase_balance(asset, who, amount, precision)
pezpallet_assets::Pezpallet::<T, I>::increase_balance(asset, who, amount, precision)
}
}
impl<T: Config<I>, I: 'static> UnbalancedHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> UnbalancedHold<T::AccountId> for Pezpallet<T, I> {
fn set_balance_on_hold(
asset: Self::AssetId,
reason: &Self::Reason,
@@ -245,7 +245,7 @@ impl<T: Config<I>, I: 'static> UnbalancedHold<T::AccountId> for Pallet<T, I> {
}
}
impl<T: Config<I>, I: 'static> MutateHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> MutateHold<T::AccountId> for Pezpallet<T, I> {
fn done_hold(
asset_id: Self::AssetId,
reason: &Self::Reason,
+23 -23
View File
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Assets Holder Pallet
//! # Assets Holder Pezpallet
//!
//! A pallet capable of holding fungibles from `pezpallet-assets`. This is an extension of
//! A pezpallet capable of holding fungibles from `pezpallet-assets`. This is an extension of
//! `pezpallet-assets`, wrapping [`fungibles::Inspect`](`pezframe_support::traits::fungibles::Inspect`).
//! It implements both
//! [`fungibles::hold::Inspect`](pezframe_support::traits::fungibles::hold::Inspect),
@@ -25,16 +25,16 @@
//! [`fungibles::hold::Unbalanced`](pezframe_support::traits::fungibles::hold::Unbalanced). The
//! complexity of the operations is `O(1)`.
//!
//! ## Pallet API
//! ## Pezpallet API
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes,
//! including its configuration trait, dispatchables, storage items, events and errors.
//!
//! ## Overview
//!
//! This pallet provides the following functionality:
//! This pezpallet provides the following functionality:
//!
//! - Pallet hooks allowing [`pezpallet-assets`] to know the balance on hold for an account on a given
//! - Pezpallet hooks allowing [`pezpallet-assets`] to know the balance on hold for an account on a given
//! asset (see [`pezpallet_assets::BalanceOnHold`]).
//! - An implementation of
//! [`fungibles::hold::Inspect`](pezframe_support::traits::fungibles::hold::Inspect),
@@ -51,7 +51,7 @@ use pezframe_support::{
};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
pub use pallet::*;
pub use pezpallet::*;
#[cfg(test)]
mod mock;
@@ -60,36 +60,36 @@ mod tests;
mod impl_fungibles;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::config(with_default)]
#[pezpallet::config(with_default)]
pub trait Config<I: 'static = ()>:
pezframe_system::Config + pezpallet_assets::Config<I, Holder = Pallet<Self, I>>
pezframe_system::Config + pezpallet_assets::Config<I, Holder = Pezpallet<Self, I>>
{
/// The overarching freeze reason.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeHoldReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount;
/// The overarching event type.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// Number of holds on an account would exceed the count of `RuntimeHoldReason`.
TooManyHolds,
}
#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(_);
#[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<I>, I: 'static = ()> {
/// `who`s balance on hold was increased by `amount`.
Held {
@@ -115,7 +115,7 @@ pub mod pallet {
}
/// A map that stores holds applied on an account for a given AssetId.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Holds<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -130,7 +130,7 @@ pub mod pallet {
>;
/// A map that stores the current total balance on hold for every account on a given AssetId.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type BalancesOnHold<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
Blake2_128Concat,
@@ -140,8 +140,8 @@ pub mod pallet {
T::Balance,
>;
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
#[cfg(feature = "try-runtime")]
fn try_state(_: BlockNumberFor<T>) -> Result<(), pezsp_runtime::TryRuntimeError> {
Self::do_try_state()
@@ -149,7 +149,7 @@ pub mod pallet {
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
#[cfg(any(test, feature = "try-runtime"))]
fn do_try_state() -> Result<(), pezsp_runtime::TryRuntimeError> {
use pezsp_runtime::{
@@ -188,7 +188,7 @@ mod impl_hold_unbalanced {
// and `increase_balance` are intentionally left out without testing, since:
// 1. It is expected these methods are tested within `pezpallet-assets`, and
// 2. There are no valid cases that can be directly asserted using those methods in
// the scope of this pallet.
// the scope of this pezpallet.
#[test]
fn set_balance_on_hold_works() {
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME asset management pallet"
description = "FRAME asset management pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-assets"
+10 -10
View File
@@ -11,10 +11,10 @@ The Assets module provides functionality for asset management of fungible asset
* Asset Destruction
To use it in your runtime, you need to implement the assets
[`assets::Config`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pallet/trait.Config.html).
[`assets::Config`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pezpallet/trait.Config.html).
The supported dispatchable functions are documented in the
[`assets::Call`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pallet/enum.Call.html) enum.
[`assets::Call`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pezpallet/enum.Call.html) enum.
### Terminology
@@ -50,7 +50,7 @@ variants for documentation on each function.
* `balance` - Get the asset `id` balance of `who`.
* `total_supply` - Get the total supply of an asset `id`.
Please refer to the [`Pallet`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pallet/struct.Pallet.html) struct for
Please refer to the [`Pezpallet`](https://docs.rs/pezpallet-assets/latest/pallet_assets/pezpallet/struct.Pezpallet.html) struct for
details on publicly available functions.
## Usage
@@ -71,20 +71,20 @@ Import the Assets module and types and derive your runtime's configuration trait
use pallet_assets as assets;
use sp_runtime::ArithmeticError;
#[frame_support::pallet]
pub mod pallet {
#[frame_support::pezpallet]
pub mod pezpallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: frame_system::Config + assets::Config {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
pub fn issue_token_airdrop(origin: OriginFor<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -145,7 +145,7 @@ where
.map_err(|_| Error::Revert(Revert { reason: ERR_INVALID_CALLER.into() }))
}
/// Convert a `U256` value to the balance type of the pallet.
/// Convert a `U256` value to the balance type of the pezpallet.
fn to_balance(
value: alloy::primitives::U256,
) -> Result<<Runtime as Config<Instance>>::Balance, Error> {
@@ -189,7 +189,7 @@ where
);
let f = TransferFlags { keep_alive: false, best_effort: false, burn_dust: false };
pezpallet_assets::Pallet::<Runtime, Instance>::do_transfer(
pezpallet_assets::Pezpallet::<Runtime, Instance>::do_transfer(
asset_id,
&<Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&from),
&dest,
@@ -219,7 +219,7 @@ where
env.charge(<Runtime as Config<Instance>>::WeightInfo::total_issuance())?;
let value =
Self::to_u256(pezpallet_assets::Pallet::<Runtime, Instance>::total_issuance(asset_id))?;
Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::total_issuance(asset_id))?;
return Ok(IERC20::totalSupplyCall::abi_encode_returns(&value));
}
@@ -233,7 +233,7 @@ where
let account = call.account.into_array().into();
let account = <Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&account);
let value =
Self::to_u256(pezpallet_assets::Pallet::<Runtime, Instance>::balance(asset_id, account))?;
Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::balance(asset_id, account))?;
return Ok(IERC20::balanceOfCall::abi_encode_returns(&value));
}
@@ -250,7 +250,7 @@ where
let spender = call.spender.into_array().into();
let spender = <Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&spender);
let value = Self::to_u256(pezpallet_assets::Pallet::<Runtime, Instance>::allowance(
let value = Self::to_u256(pezpallet_assets::Pezpallet::<Runtime, Instance>::allowance(
asset_id, &owner, &spender,
))?;
@@ -268,7 +268,7 @@ where
let spender = call.spender.into_array().into();
let spender = <Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&spender);
pezpallet_assets::Pallet::<Runtime, Instance>::do_approve_transfer(
pezpallet_assets::Pezpallet::<Runtime, Instance>::do_approve_transfer(
asset_id,
&<Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&owner),
&spender,
@@ -303,7 +303,7 @@ where
let to = call.to.into_array().into();
let to = <Runtime as pezpallet_revive::Config>::AddressMapper::to_account_id(&to);
pezpallet_assets::Pallet::<Runtime, Instance>::do_transfer_approved(
pezpallet_assets::Pezpallet::<Runtime, Instance>::do_transfer_approved(
asset_id,
&from,
&spender,
@@ -72,7 +72,7 @@ fn precompile_transfer_works() {
let data =
IERC20::transferCall { to: to_addr.0.into(), value: U256::from(10) }.abi_encode();
pezpallet_revive::Pallet::<Test>::bare_call(
pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(from),
H160::from(asset_addr),
0u32.into(),
@@ -111,7 +111,7 @@ fn total_supply_works() {
let data = IERC20::totalSupplyCall {}.abi_encode();
let data = pezpallet_revive::Pallet::<Test>::bare_call(
let data = pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(owner),
H160::from(asset_addr),
0u32.into(),
@@ -144,7 +144,7 @@ fn balance_of_works() {
let account = <Test as pezpallet_revive::Config>::AddressMapper::to_address(&owner).0.into();
let data = IERC20::balanceOfCall { account }.abi_encode();
let data = pezpallet_revive::Pallet::<Test>::bare_call(
let data = pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(owner),
H160::from(asset_addr),
0u32.into(),
@@ -190,7 +190,7 @@ fn approval_works() {
let data = IERC20::approveCall { spender: spender_addr.0.into(), value: U256::from(25) }
.abi_encode();
pezpallet_revive::Pallet::<Test>::bare_call(
pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(owner),
H160::from(asset_addr),
0u32.into(),
@@ -213,7 +213,7 @@ fn approval_works() {
IERC20::allowanceCall { owner: owner_addr.0.into(), spender: spender_addr.0.into() }
.abi_encode();
let data = pezpallet_revive::Pallet::<Test>::bare_call(
let data = pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(owner),
H160::from(asset_addr),
0u32.into(),
@@ -236,7 +236,7 @@ fn approval_works() {
}
.abi_encode();
pezpallet_revive::Pallet::<Test>::bare_call(
pezpallet_revive::Pezpallet::<Test>::bare_call(
RuntimeOrigin::signed(spender),
H160::from(asset_addr),
0u32.into(),
+10 -10
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Assets pallet benchmarking.
//! Assets pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
@@ -31,7 +31,7 @@ use pezframe_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable};
use pezframe_system::RawOrigin as SystemOrigin;
use pezsp_runtime::{traits::Bounded, Weight};
use crate::Pallet as Assets;
use crate::Pezpallet as Assets;
const SEED: u32 = 0;
const MIN_BALANCE: u32 = 1;
@@ -147,11 +147,11 @@ fn add_approvals<T: Config<I>, I: 'static>(minter: T::AccountId, n: u32) {
}
fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
}
fn assert_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
pezframe_system::Pallet::<T>::assert_has_event(generic_event.into());
pezframe_system::Pezpallet::<T>::assert_has_event(generic_event.into());
}
benchmarks_instance_pallet! {
@@ -272,7 +272,7 @@ benchmarks_instance_pallet! {
let target_lookup = T::Lookup::unlookup(target.clone());
}: _(SystemOrigin::Signed(caller.clone()), asset_id.clone(), target_lookup, amount)
verify {
assert!(pezframe_system::Pallet::<T>::account_exists(&caller));
assert!(pezframe_system::Pezpallet::<T>::account_exists(&caller));
assert_last_event::<T, I>(Event::Transferred { asset_id: asset_id.into(), from: caller, to: target, amount }.into());
}
@@ -592,7 +592,7 @@ benchmarks_instance_pallet! {
let (asset_id, _, _) = create_default_minted_asset::<T, I>(true, 100u32.into());
let amount;
}: {
amount = Pallet::<T, I>::total_issuance(asset_id.into());
amount = Pezpallet::<T, I>::total_issuance(asset_id.into());
} verify {
assert_eq!(amount, 100u32.into());
}
@@ -601,7 +601,7 @@ benchmarks_instance_pallet! {
let (asset_id, caller, _) = create_default_minted_asset::<T, I>(true, 100u32.into());
let amount;
}: {
amount = Pallet::<T, I>::balance(asset_id.into(), caller);
amount = Pezpallet::<T, I>::balance(asset_id.into(), caller);
} verify {
assert_eq!(amount, 100u32.into());
}
@@ -613,20 +613,20 @@ benchmarks_instance_pallet! {
let delegate: T::AccountId = account("approval", 0, SEED);
let amount;
}: {
amount = Pallet::<T, I>::allowance(asset_id.into(), &caller, &delegate);
amount = Pezpallet::<T, I>::allowance(asset_id.into(), &caller, &delegate);
} verify {
assert_eq!(amount, 100u32.into());
}
migration_v2_foreign_asset_set_reserve_weight {
let (id, _, _) = create_default_asset::<T, I>(true);
let id: <T as pallet::Config<I>>::AssetId = id.into();
let id: <T as pezpallet::Config<I>>::AssetId = id.into();
let reserve = T::BenchmarkHelper::create_reserve_id_parameter(42);
}: {
let asset_id = Asset::<T, I>::iter_keys().next()
.ok_or_else(|| BenchmarkError::Override(BenchmarkResult::from_weight(Weight::MAX)))?;
assert_eq!(id, asset_id);
Pallet::<T, I>::unchecked_update_reserves(asset_id, vec![reserve.clone()]).unwrap();
Pezpallet::<T, I>::unchecked_update_reserves(asset_id, vec![reserve.clone()]).unwrap();
}
verify {
assert_eq!(Reserves::<T, I>::get(id)[0], reserve);
@@ -21,7 +21,7 @@ use super::*;
/// A mutator type allowing inspection and possible modification of the extra "sidecar" data.
///
/// This may be used as a `Deref` for the pallet's extra data. If mutated (using `DerefMut`), then
/// This may be used as a `Deref` for the pezpallet's extra data. If mutated (using `DerefMut`), then
/// any uncommitted changes (see `commit` function) will be automatically committed to storage when
/// dropped. Changes, even after committed, may be reverted to their original values with the
/// `revert` function.
+9 -9
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Functions for the Assets pallet.
//! Functions for the Assets pezpallet.
use super::*;
use alloc::vec;
@@ -30,7 +30,7 @@ pub(super) enum DeadConsequence {
use DeadConsequence::*;
// The main implementation block for the module.
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
// Public immutables
/// Return the extra "sid-car" data for `id`/`who`, or `None` if the account doesn't exist.
@@ -77,16 +77,16 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
ExistenceReason::DepositFrom(depositor.clone(), deposit)
}
} else if d.is_sufficient {
pezframe_system::Pallet::<T>::inc_sufficients(who);
pezframe_system::Pezpallet::<T>::inc_sufficients(who);
d.sufficients.saturating_inc();
ExistenceReason::Sufficient
} else {
pezframe_system::Pallet::<T>::inc_consumers(who)
pezframe_system::Pezpallet::<T>::inc_consumers(who)
.map_err(|_| Error::<T, I>::UnavailableConsumer)?;
// We ensure that we can still increment consumers once more because we could otherwise
// allow accidental usage of all consumer references which could cause grief.
if !pezframe_system::Pallet::<T>::can_inc_consumer(who) {
pezframe_system::Pallet::<T>::dec_consumers(who);
if !pezframe_system::Pezpallet::<T>::can_inc_consumer(who) {
pezframe_system::Pezpallet::<T>::dec_consumers(who);
return Err(Error::<T, I>::UnavailableConsumer.into());
}
ExistenceReason::Consumer
@@ -113,10 +113,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
use ExistenceReason::*;
match *reason {
Consumer => pezframe_system::Pallet::<T>::dec_consumers(who),
Consumer => pezframe_system::Pezpallet::<T>::dec_consumers(who),
Sufficient => {
d.sufficients = d.sufficients.saturating_sub(1);
pezframe_system::Pallet::<T>::dec_sufficients(who);
pezframe_system::Pezpallet::<T>::dec_sufficients(who);
},
DepositRefunded => {},
DepositHeld(_) | DepositFrom(..) if !force => return Keep,
@@ -160,7 +160,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if amount < details.min_balance {
return DepositConsequence::BelowMinimum;
}
if !details.is_sufficient && !pezframe_system::Pallet::<T>::can_accrue_consumers(who, 2) {
if !details.is_sufficient && !pezframe_system::Pezpallet::<T>::can_accrue_consumers(who, 2) {
return DepositConsequence::CannotCreate;
}
if details.is_sufficient && details.sufficients.checked_add(1).is_none() {
@@ -30,7 +30,7 @@ use pezframe_support::{
use super::*;
impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pezpallet<T, I> {
type AssetId = T::AssetId;
type Balance = T::Balance;
@@ -43,11 +43,11 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
}
fn balance(asset: Self::AssetId, who: &<T as SystemConfig>::AccountId) -> Self::Balance {
Pallet::<T, I>::balance(asset, who)
Pezpallet::<T, I>::balance(asset, who)
}
fn total_balance(asset: Self::AssetId, who: &<T as SystemConfig>::AccountId) -> Self::Balance {
Pallet::<T, I>::balance(asset.clone(), who)
Pezpallet::<T, I>::balance(asset.clone(), who)
.saturating_add(T::Holder::balance_on_hold(asset, who).unwrap_or_default())
}
@@ -57,7 +57,7 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
preservation: Preservation,
_: Fortitude,
) -> Self::Balance {
Pallet::<T, I>::reducible_balance(asset, who, !matches!(preservation, Expendable))
Pezpallet::<T, I>::reducible_balance(asset, who, !matches!(preservation, Expendable))
.unwrap_or(Zero::zero())
}
@@ -67,7 +67,7 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
amount: Self::Balance,
provenance: Provenance,
) -> DepositConsequence {
Pallet::<T, I>::can_increase(asset, who, amount, provenance == Minted)
Pezpallet::<T, I>::can_increase(asset, who, amount, provenance == Minted)
}
fn can_withdraw(
@@ -75,7 +75,7 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
who: &<T as SystemConfig>::AccountId,
amount: Self::Balance,
) -> WithdrawConsequence<Self::Balance> {
Pallet::<T, I>::can_decrease(asset, who, amount, false)
Pezpallet::<T, I>::can_decrease(asset, who, amount, false)
}
fn asset_exists(asset: Self::AssetId) -> bool {
@@ -83,7 +83,7 @@ impl<T: Config<I>, I: 'static> fungibles::Inspect<<T as SystemConfig>::AccountId
}
}
impl<T: Config<I>, I: 'static> fungibles::Mutate<<T as SystemConfig>::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Mutate<<T as SystemConfig>::AccountId> for Pezpallet<T, I> {
fn done_mint_into(
asset_id: Self::AssetId,
beneficiary: &<T as SystemConfig>::AccountId,
@@ -116,7 +116,7 @@ impl<T: Config<I>, I: 'static> fungibles::Mutate<<T as SystemConfig>::AccountId>
}
impl<T: Config<I>, I: 'static> fungibles::Balanced<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
type OnDropCredit = fungibles::DecreaseIssuance<T::AccountId, Self>;
type OnDropDebt = fungibles::IncreaseIssuance<T::AccountId, Self>;
@@ -138,7 +138,7 @@ impl<T: Config<I>, I: 'static> fungibles::Balanced<<T as SystemConfig>::AccountI
}
}
impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pezpallet<T, I> {
fn handle_raw_dust(_: Self::AssetId, _: Self::Balance) {}
fn handle_dust(_: fungibles::Dust<T::AccountId, Self>) {
defensive!("`decrease_balance` and `increase_balance` have non-default impls; nothing else calls this; qed");
@@ -185,7 +185,7 @@ impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pallet<T,
// TODO: #13196 implement deactivate/reactivate once we have inactive balance tracking.
}
impl<T: Config<I>, I: 'static> fungibles::Create<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Create<T::AccountId> for Pezpallet<T, I> {
fn create(
id: T::AssetId,
admin: T::AccountId,
@@ -196,7 +196,7 @@ impl<T: Config<I>, I: 'static> fungibles::Create<T::AccountId> for Pallet<T, I>
}
}
impl<T: Config<I>, I: 'static> fungibles::Destroy<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Destroy<T::AccountId> for Pezpallet<T, I> {
fn start_destroy(id: T::AssetId, maybe_check_owner: Option<T::AccountId>) -> DispatchResult {
Self::do_start_destroy(id, maybe_check_owner)
}
@@ -215,7 +215,7 @@ impl<T: Config<I>, I: 'static> fungibles::Destroy<T::AccountId> for Pallet<T, I>
}
impl<T: Config<I>, I: 'static> fungibles::metadata::Inspect<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn name(asset: T::AssetId) -> Vec<u8> {
Metadata::<T, I>::get(asset).name.to_vec()
@@ -231,7 +231,7 @@ impl<T: Config<I>, I: 'static> fungibles::metadata::Inspect<<T as SystemConfig>:
}
impl<T: Config<I>, I: 'static> fungibles::metadata::Mutate<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn set(
asset: T::AssetId,
@@ -247,7 +247,7 @@ impl<T: Config<I>, I: 'static> fungibles::metadata::Mutate<<T as SystemConfig>::
impl<T: Config<I>, I: 'static>
fungibles::metadata::MetadataDeposit<
<T::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance,
> for Pallet<T, I>
> for Pezpallet<T, I>
{
fn calc_metadata_deposit(
name: &[u8],
@@ -258,7 +258,7 @@ impl<T: Config<I>, I: 'static>
}
impl<T: Config<I>, I: 'static> fungibles::approvals::Inspect<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
// Check the amount approved to be spent by an owner to a delegate
fn allowance(
@@ -273,7 +273,7 @@ impl<T: Config<I>, I: 'static> fungibles::approvals::Inspect<<T as SystemConfig>
}
impl<T: Config<I>, I: 'static> fungibles::approvals::Mutate<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
// Approve spending tokens from a given account
fn approve(
@@ -297,7 +297,7 @@ impl<T: Config<I>, I: 'static> fungibles::approvals::Mutate<<T as SystemConfig>:
}
impl<T: Config<I>, I: 'static> fungibles::roles::Inspect<<T as SystemConfig>::AccountId>
for Pallet<T, I>
for Pezpallet<T, I>
{
fn owner(asset: T::AssetId) -> Option<<T as SystemConfig>::AccountId> {
Asset::<T, I>::get(asset).map(|x| x.owner)
@@ -316,7 +316,7 @@ impl<T: Config<I>, I: 'static> fungibles::roles::Inspect<<T as SystemConfig>::Ac
}
}
impl<T: Config<I>, I: 'static> fungibles::InspectEnumerable<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::InspectEnumerable<T::AccountId> for Pezpallet<T, I> {
type AssetsIterator = KeyPrefixIterator<<T as Config<I>>::AssetId>;
/// Returns an iterator of the assets in existence.
@@ -327,7 +327,7 @@ impl<T: Config<I>, I: 'static> fungibles::InspectEnumerable<T::AccountId> for Pa
}
}
impl<T: Config<I>, I: 'static> fungibles::roles::ResetTeam<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::roles::ResetTeam<T::AccountId> for Pezpallet<T, I> {
fn reset_team(
id: T::AssetId,
owner: T::AccountId,
@@ -339,7 +339,7 @@ impl<T: Config<I>, I: 'static> fungibles::roles::ResetTeam<T::AccountId> for Pal
}
}
impl<T: Config<I>, I: 'static> fungibles::Refund<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungibles::Refund<T::AccountId> for Pezpallet<T, I> {
type AssetId = T::AssetId;
type Balance = DepositBalanceOf<T, I>;
fn deposit_held(id: Self::AssetId, who: T::AccountId) -> Option<(T::AccountId, Self::Balance)> {
@@ -15,11 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Assets pallet's `StoredMap` implementation.
//! Assets pezpallet's `StoredMap` implementation.
use super::*;
impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> for Pezpallet<T, I> {
fn get(id_who: &(T::AssetId, T::AccountId)) -> T::Extra {
let (id, who) = id_who;
Account::<T, I>::get(id, who).map(|a| a.extra).unwrap_or_default()
+104 -104
View File
@@ -15,17 +15,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Assets Pallet
//! # Assets Pezpallet
//!
//! A simple, secure module for dealing with sets of assets implementing
//! [`fungible`](pezframe_support::traits::fungible) traits, via [`fungibles`] traits.
//!
//! The pallet makes heavy use of concepts such as Holds and Freezes from the
//! The pezpallet makes heavy use of concepts such as Holds and Freezes from the
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those docs
//! as a prerequisite to understanding this pallet.
//! as a prerequisite to understanding this pezpallet.
//!
//! See the [`frame_tokens`] reference docs for more information about the place of the
//! Assets pallet in FRAME.
//! Assets pezpallet in FRAME.
//!
//! ## Overview
//!
@@ -131,7 +131,7 @@
//! * `balance` - Get the asset `id` balance of `who`.
//! * `total_supply` - Get the total supply of an asset `id`.
//!
//! Please refer to the [`Pallet`] struct for details on publicly available functions.
//! Please refer to the [`Pezpallet`] struct for details on publicly available functions.
//!
//! ### Callbacks
//!
@@ -196,7 +196,7 @@ use pezframe_support::{
};
use pezframe_system::Config as SystemConfig;
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
type AccountIdLookupOf<T> = <<T as pezframe_system::Config>::Lookup as StaticLookup>::Source;
@@ -247,8 +247,8 @@ where
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use codec::HasCompact;
use pezframe_support::{
@@ -263,9 +263,9 @@ pub mod pallet {
/// The maximum number of configurable reserve locations for one asset class.
pub const MAX_RESERVES: u32 = 5;
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T, I = ()>(_);
#[cfg(feature = "runtime-benchmarks")]
pub trait BenchmarkHelper<AssetIdParameter, ReserveIdParameter> {
@@ -316,11 +316,11 @@ pub mod pallet {
}
}
#[pallet::config(with_default)]
#[pezpallet::config(with_default)]
/// The module configuration trait.
pub trait Config<I: 'static = ()>: pezframe_system::Config {
/// The overarching event type.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
@@ -339,14 +339,14 @@ pub mod pallet {
/// Max number of items to destroy per `destroy_accounts` and `destroy_approvals` call.
///
/// Must be configured to result in a weight that makes each call fit in a block.
#[pallet::constant]
#[pezpallet::constant]
type RemoveItemsLimit: Get<u32>;
/// Identifier for the class of asset.
type AssetId: Member + Parameter + Clone + MaybeSerializeDeserialize + MaxEncodedLen;
/// Wrapper around `Self::AssetId` to use in dispatchable call signatures. Allows the use
/// of compact encoding in instances of the pallet, which will prevent breaking changes
/// of compact encoding in instances of the pezpallet, which will prevent breaking changes
/// resulting from the removal of `HasCompact` from `Self::AssetId`.
///
/// This type includes the `From<Self::AssetId>` bound, since tightly coupled pallets may
@@ -358,12 +358,12 @@ pub mod pallet {
type ReserveData: Debug + Parameter + MaybeSerializeDeserialize + MaxEncodedLen;
/// The currency mechanism.
#[pallet::no_default]
#[pezpallet::no_default]
type Currency: ReservableCurrency<Self::AccountId>;
/// Standard asset class creation is only allowed if the origin attempting it and the
/// asset class are in this set.
#[pallet::no_default]
#[pezpallet::no_default]
type CreateOrigin: EnsureOriginWithArg<
Self::RuntimeOrigin,
Self::AssetId,
@@ -372,38 +372,38 @@ pub mod pallet {
/// The origin which may forcibly create or destroy an asset or otherwise alter privileged
/// attributes.
#[pallet::no_default]
#[pezpallet::no_default]
type ForceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The basic amount of funds that must be reserved for an asset.
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type AssetDeposit: Get<DepositBalanceOf<Self, I>>;
/// The amount of funds that must be reserved for a non-provider asset account to be
/// maintained.
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type AssetAccountDeposit: Get<DepositBalanceOf<Self, I>>;
/// The basic amount of funds that must be reserved when adding metadata to your asset.
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type MetadataDepositBase: Get<DepositBalanceOf<Self, I>>;
/// The additional funds that must be reserved for the number of bytes you store in your
/// metadata.
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type MetadataDepositPerByte: Get<DepositBalanceOf<Self, I>>;
/// The amount of funds that must be reserved when creating a new approval.
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type ApprovalDeposit: Get<DepositBalanceOf<Self, I>>;
/// The maximum length of a name or symbol stored on-chain.
#[pallet::constant]
#[pezpallet::constant]
type StringLimit: Get<u32>;
/// A hook to allow a per-asset, per-account minimum balance to be enforced. This must be
@@ -425,7 +425,7 @@ pub mod pallet {
/// used to set up auto-incrementing asset IDs for this collection.
type CallbackHandle: AssetsCallback<Self::AssetId, Self::AccountId>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// Helper trait for benchmarks.
@@ -433,7 +433,7 @@ pub mod pallet {
type BenchmarkHelper: BenchmarkHelper<Self::AssetIdParameter, Self::ReserveData>;
}
#[pallet::storage]
#[pezpallet::storage]
/// Details of an asset.
pub type Asset<T: Config<I>, I: 'static = ()> = StorageMap<
_,
@@ -442,7 +442,7 @@ pub mod pallet {
AssetDetails<T::Balance, T::AccountId, DepositBalanceOf<T, I>>,
>;
#[pallet::storage]
#[pezpallet::storage]
/// The holdings of a specific account for a specific asset.
pub type Account<T: Config<I>, I: 'static = ()> = StorageDoubleMap<
_,
@@ -453,7 +453,7 @@ pub mod pallet {
AssetAccountOf<T, I>,
>;
#[pallet::storage]
#[pezpallet::storage]
/// Approved balance transfers. First balance is the amount approved for transfer. Second
/// is the amount of `T::Currency` reserved for storing this.
/// First key is the asset ID, second key is the owner and third key is the delegate.
@@ -467,7 +467,7 @@ pub mod pallet {
Approval<T::Balance, DepositBalanceOf<T, I>>,
>;
#[pallet::storage]
#[pezpallet::storage]
/// Metadata of an asset.
pub type Metadata<T: Config<I>, I: 'static = ()> = StorageMap<
_,
@@ -478,7 +478,7 @@ pub mod pallet {
>;
/// Maps an asset to a list of its configured reserve information.
#[pallet::storage]
#[pezpallet::storage]
pub type Reserves<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
@@ -496,10 +496,10 @@ pub mod pallet {
///
/// The initial next asset ID can be set using the [`GenesisConfig`] or the
/// [SetNextAssetId](`migration::next_asset_id::SetNextAssetId`) migration.
#[pallet::storage]
#[pezpallet::storage]
pub type NextAssetId<T: Config<I>, I: 'static = ()> = StorageValue<_, T::AssetId, OptionQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// Genesis assets: id, owner, is_sufficient, min_balance
@@ -519,7 +519,7 @@ pub mod pallet {
pub reserves: Vec<(T::AssetId, Vec<T::ReserveData>)>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
for (id, owner, is_sufficient, min_balance) in &self.assets {
@@ -563,7 +563,7 @@ pub mod pallet {
}
for (id, account_id, amount) in &self.accounts {
let result = <Pallet<T, I>>::increase_balance(
let result = <Pezpallet<T, I>>::increase_balance(
id.clone(),
account_id,
*amount,
@@ -591,8 +591,8 @@ pub mod pallet {
}
}
#[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<I>, I: 'static = ()> {
/// Some asset class was created.
Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId },
@@ -684,7 +684,7 @@ pub mod pallet {
ReservesRemoved { asset_id: T::AssetId },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// Account balance must be greater than or equal to the transfer amount.
BalanceLow,
@@ -739,8 +739,8 @@ pub mod pallet {
TooManyReserves,
}
#[pallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Issue a new class of fungible assets from a public origin.
///
/// This new asset class has no assets initially and its owner is the origin.
@@ -760,7 +760,7 @@ pub mod pallet {
/// Emits `Created` event when successful.
///
/// Weight: `O(1)`
#[pallet::call_index(0)]
#[pezpallet::call_index(0)]
pub fn create(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -827,13 +827,13 @@ pub mod pallet {
/// Emits `ForceCreated` event when successful.
///
/// Weight: `O(1)`
#[pallet::call_index(1)]
#[pezpallet::call_index(1)]
pub fn force_create(
origin: OriginFor<T>,
id: T::AssetIdParameter,
owner: AccountIdLookupOf<T>,
is_sufficient: bool,
#[pallet::compact] min_balance: T::Balance,
#[pezpallet::compact] min_balance: T::Balance,
) -> DispatchResult {
T::ForceOrigin::ensure_origin(origin)?;
let owner = T::Lookup::lookup(owner)?;
@@ -853,7 +853,7 @@ pub mod pallet {
///
/// It will fail with either [`Error::ContainsHolds`] or [`Error::ContainsFreezes`] if
/// an account contains holds or freezes in place.
#[pallet::call_index(2)]
#[pezpallet::call_index(2)]
pub fn start_destroy(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
let maybe_check_owner = match T::ForceOrigin::try_origin(origin) {
Ok(_) => None,
@@ -875,8 +875,8 @@ pub mod pallet {
/// asset.
///
/// Each call emits the `Event::DestroyedAccounts` event.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::destroy_accounts(T::RemoveItemsLimit::get()))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::destroy_accounts(T::RemoveItemsLimit::get()))]
pub fn destroy_accounts(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -899,8 +899,8 @@ pub mod pallet {
/// asset.
///
/// Each call emits the `Event::DestroyedApprovals` event.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::destroy_approvals(T::RemoveItemsLimit::get()))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::destroy_approvals(T::RemoveItemsLimit::get()))]
pub fn destroy_approvals(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -921,7 +921,7 @@ pub mod pallet {
/// asset.
///
/// Each successful call emits the `Event::Destroyed` event.
#[pallet::call_index(5)]
#[pezpallet::call_index(5)]
pub fn finish_destroy(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
ensure_signed(origin)?;
let id: T::AssetId = id.into();
@@ -940,12 +940,12 @@ pub mod pallet {
///
/// Weight: `O(1)`
/// Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
#[pallet::call_index(6)]
#[pezpallet::call_index(6)]
pub fn mint(
origin: OriginFor<T>,
id: T::AssetIdParameter,
beneficiary: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let beneficiary = T::Lookup::lookup(beneficiary)?;
@@ -969,12 +969,12 @@ pub mod pallet {
///
/// Weight: `O(1)`
/// Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
#[pallet::call_index(7)]
#[pezpallet::call_index(7)]
pub fn burn(
origin: OriginFor<T>,
id: T::AssetIdParameter,
who: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let who = T::Lookup::lookup(who)?;
@@ -1003,12 +1003,12 @@ pub mod pallet {
/// Weight: `O(1)`
/// Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
/// `target`.
#[pallet::call_index(8)]
#[pezpallet::call_index(8)]
pub fn transfer(
origin: OriginFor<T>,
id: T::AssetIdParameter,
target: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let dest = T::Lookup::lookup(target)?;
@@ -1036,12 +1036,12 @@ pub mod pallet {
/// Weight: `O(1)`
/// Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
/// `target`.
#[pallet::call_index(9)]
#[pezpallet::call_index(9)]
pub fn transfer_keep_alive(
origin: OriginFor<T>,
id: T::AssetIdParameter,
target: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let source = ensure_signed(origin)?;
let dest = T::Lookup::lookup(target)?;
@@ -1070,13 +1070,13 @@ pub mod pallet {
/// Weight: `O(1)`
/// Modes: Pre-existence of `dest`; Post-existence of `source`; Account pre-existence of
/// `dest`.
#[pallet::call_index(10)]
#[pezpallet::call_index(10)]
pub fn force_transfer(
origin: OriginFor<T>,
id: T::AssetIdParameter,
source: AccountIdLookupOf<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let source = T::Lookup::lookup(source)?;
@@ -1099,7 +1099,7 @@ pub mod pallet {
/// Emits `Frozen`.
///
/// Weight: `O(1)`
#[pallet::call_index(11)]
#[pezpallet::call_index(11)]
pub fn freeze(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1136,7 +1136,7 @@ pub mod pallet {
/// Emits `Thawed`.
///
/// Weight: `O(1)`
#[pallet::call_index(12)]
#[pezpallet::call_index(12)]
pub fn thaw(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1172,7 +1172,7 @@ pub mod pallet {
/// Emits `Frozen`.
///
/// Weight: `O(1)`
#[pallet::call_index(13)]
#[pezpallet::call_index(13)]
pub fn freeze_asset(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
let origin = ensure_signed(origin)?;
let id: T::AssetId = id.into();
@@ -1198,7 +1198,7 @@ pub mod pallet {
/// Emits `Thawed`.
///
/// Weight: `O(1)`
#[pallet::call_index(14)]
#[pezpallet::call_index(14)]
pub fn thaw_asset(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
let origin = ensure_signed(origin)?;
let id: T::AssetId = id.into();
@@ -1225,7 +1225,7 @@ pub mod pallet {
/// Emits `OwnerChanged`.
///
/// Weight: `O(1)`
#[pallet::call_index(15)]
#[pezpallet::call_index(15)]
pub fn transfer_ownership(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1268,7 +1268,7 @@ pub mod pallet {
/// Emits `TeamChanged`.
///
/// Weight: `O(1)`
#[pallet::call_index(16)]
#[pezpallet::call_index(16)]
pub fn set_team(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1312,8 +1312,8 @@ pub mod pallet {
/// Emits `MetadataSet`.
///
/// Weight: `O(1)`
#[pallet::call_index(17)]
#[pallet::weight(T::WeightInfo::set_metadata(name.len() as u32, symbol.len() as u32))]
#[pezpallet::call_index(17)]
#[pezpallet::weight(T::WeightInfo::set_metadata(name.len() as u32, symbol.len() as u32))]
pub fn set_metadata(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1337,7 +1337,7 @@ pub mod pallet {
/// Emits `MetadataCleared`.
///
/// Weight: `O(1)`
#[pallet::call_index(18)]
#[pezpallet::call_index(18)]
pub fn clear_metadata(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
let origin = ensure_signed(origin)?;
let id: T::AssetId = id.into();
@@ -1368,8 +1368,8 @@ pub mod pallet {
/// Emits `MetadataSet`.
///
/// Weight: `O(N + S)` where N and S are the length of the name and symbol respectively.
#[pallet::call_index(19)]
#[pallet::weight(T::WeightInfo::force_set_metadata(name.len() as u32, symbol.len() as u32))]
#[pezpallet::call_index(19)]
#[pezpallet::weight(T::WeightInfo::force_set_metadata(name.len() as u32, symbol.len() as u32))]
pub fn force_set_metadata(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1420,7 +1420,7 @@ pub mod pallet {
/// Emits `MetadataCleared`.
///
/// Weight: `O(1)`
#[pallet::call_index(20)]
#[pezpallet::call_index(20)]
pub fn force_clear_metadata(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1451,7 +1451,7 @@ pub mod pallet {
/// - `is_sufficient`: Whether a non-zero balance of this asset is deposit of sufficient
/// value to account for the state bloat associated with its balance storage. If set to
/// `true`, then non-zero balances may be stored without a `consumer` reference (and thus
/// an ED in the Balances pallet or whatever else is used to control user-account state
/// an ED in the Balances pezpallet or whatever else is used to control user-account state
/// growth).
/// - `is_frozen`: Whether this asset class is frozen except for permissioned/admin
/// instructions.
@@ -1459,7 +1459,7 @@ pub mod pallet {
/// Emits `AssetStatusChanged` with the identity of the asset.
///
/// Weight: `O(1)`
#[pallet::call_index(21)]
#[pezpallet::call_index(21)]
pub fn force_asset_status(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1467,7 +1467,7 @@ pub mod pallet {
issuer: AccountIdLookupOf<T>,
admin: AccountIdLookupOf<T>,
freezer: AccountIdLookupOf<T>,
#[pallet::compact] min_balance: T::Balance,
#[pezpallet::compact] min_balance: T::Balance,
is_sufficient: bool,
is_frozen: bool,
) -> DispatchResult {
@@ -1515,12 +1515,12 @@ pub mod pallet {
/// Emits `ApprovedTransfer` on success.
///
/// Weight: `O(1)`
#[pallet::call_index(22)]
#[pezpallet::call_index(22)]
pub fn approve_transfer(
origin: OriginFor<T>,
id: T::AssetIdParameter,
delegate: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let owner = ensure_signed(origin)?;
let delegate = T::Lookup::lookup(delegate)?;
@@ -1541,7 +1541,7 @@ pub mod pallet {
/// Emits `ApprovalCancelled` on success.
///
/// Weight: `O(1)`
#[pallet::call_index(23)]
#[pezpallet::call_index(23)]
pub fn cancel_approval(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1577,7 +1577,7 @@ pub mod pallet {
/// Emits `ApprovalCancelled` on success.
///
/// Weight: `O(1)`
#[pallet::call_index(24)]
#[pezpallet::call_index(24)]
pub fn force_cancel_approval(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1626,13 +1626,13 @@ pub mod pallet {
/// Emits `TransferredApproved` on success.
///
/// Weight: `O(1)`
#[pallet::call_index(25)]
#[pezpallet::call_index(25)]
pub fn transfer_approved(
origin: OriginFor<T>,
id: T::AssetIdParameter,
owner: AccountIdLookupOf<T>,
destination: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
#[pezpallet::compact] amount: T::Balance,
) -> DispatchResult {
let delegate = ensure_signed(origin)?;
let owner = T::Lookup::lookup(owner)?;
@@ -1650,8 +1650,8 @@ pub mod pallet {
/// - `id`: The identifier of the asset for the account to be created.
///
/// Emits `Touched` event when successful.
#[pallet::call_index(26)]
#[pallet::weight(T::WeightInfo::touch())]
#[pezpallet::call_index(26)]
#[pezpallet::weight(T::WeightInfo::touch())]
pub fn touch(origin: OriginFor<T>, id: T::AssetIdParameter) -> DispatchResult {
let who = ensure_signed(origin)?;
let id: T::AssetId = id.into();
@@ -1671,8 +1671,8 @@ pub mod pallet {
/// the asset account contains holds or freezes in place.
///
/// Emits `Refunded` event when successful.
#[pallet::call_index(27)]
#[pallet::weight(T::WeightInfo::refund())]
#[pezpallet::call_index(27)]
#[pezpallet::weight(T::WeightInfo::refund())]
pub fn refund(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1694,7 +1694,7 @@ pub mod pallet {
/// - `min_balance`: The new value of `min_balance`.
///
/// Emits `AssetMinBalanceChanged` event when successful.
#[pallet::call_index(28)]
#[pezpallet::call_index(28)]
pub fn set_min_balance(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1739,8 +1739,8 @@ pub mod pallet {
/// - `who`: The account to be created.
///
/// Emits `Touched` event when successful.
#[pallet::call_index(29)]
#[pallet::weight(T::WeightInfo::touch_other())]
#[pezpallet::call_index(29)]
#[pezpallet::weight(T::WeightInfo::touch_other())]
pub fn touch_other(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1765,8 +1765,8 @@ pub mod pallet {
/// the asset account contains holds or freezes in place.
///
/// Emits `Refunded` event when successful.
#[pallet::call_index(30)]
#[pallet::weight(T::WeightInfo::refund_other())]
#[pezpallet::call_index(30)]
#[pezpallet::weight(T::WeightInfo::refund_other())]
pub fn refund_other(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1788,7 +1788,7 @@ pub mod pallet {
/// Emits `Blocked`.
///
/// Weight: `O(1)`
#[pallet::call_index(31)]
#[pezpallet::call_index(31)]
pub fn block(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1831,8 +1831,8 @@ pub mod pallet {
/// of the funds the asset account has, causing the sender asset account to be killed
/// (false), or transfer everything except at least the minimum balance, which will
/// guarantee to keep the sender asset account alive (true).
#[pallet::call_index(32)]
#[pallet::weight(T::WeightInfo::transfer_all())]
#[pezpallet::call_index(32)]
#[pezpallet::weight(T::WeightInfo::transfer_all())]
pub fn transfer_all(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1867,8 +1867,8 @@ pub mod pallet {
/// - `reserves`: The full list of trusted reserves information.
///
/// Emits `AssetMinBalanceChanged` event when successful.
#[pallet::call_index(33)]
#[pallet::weight(T::WeightInfo::set_reserves())]
#[pezpallet::call_index(33)]
#[pezpallet::weight(T::WeightInfo::set_reserves())]
pub fn set_reserves(
origin: OriginFor<T>,
id: T::AssetIdParameter,
@@ -1886,8 +1886,8 @@ pub mod pallet {
}
}
#[pallet::view_functions]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::view_functions]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Provide the asset details for asset `id`.
pub fn asset_details(
id: T::AssetId,
@@ -1915,7 +1915,7 @@ pub mod pallet {
/// Implements [`AccountTouch`] trait.
/// Note that a depositor can be any account, without any specific privilege.
impl<T: Config<I>, I: 'static> AccountTouch<T::AssetId, T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> AccountTouch<T::AssetId, T::AccountId> for Pezpallet<T, I> {
type Balance = DepositBalanceOf<T, I>;
fn deposit_required(_: T::AssetId) -> Self::Balance {
@@ -1926,7 +1926,7 @@ pub mod pallet {
match Asset::<T, I>::get(&asset) {
// refer to the [`Self::new_account`] function for more details.
Some(info) if info.is_sufficient => false,
Some(_) if pezframe_system::Pallet::<T>::can_accrue_consumers(who, 2) => false,
Some(_) if pezframe_system::Pezpallet::<T>::can_accrue_consumers(who, 2) => false,
Some(_) => !Account::<T, I>::contains_key(asset, who),
_ => true,
}
@@ -1942,7 +1942,7 @@ pub mod pallet {
}
/// Implements [`ContainsPair`] trait for a pair of asset and account IDs.
impl<T: Config<I>, I: 'static> ContainsPair<T::AssetId, T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> ContainsPair<T::AssetId, T::AccountId> for Pezpallet<T, I> {
/// Check if an account with the given asset ID and account address exists.
fn contains(asset: &T::AssetId, who: &T::AccountId) -> bool {
Account::<T, I>::contains_key(asset, who)
@@ -1951,7 +1951,7 @@ pub mod pallet {
/// Implements [`ProvideAssetReserves`] trait for getting the list of trusted reserves for a
/// given asset.
impl<T: Config<I>, I: 'static> ProvideAssetReserves<T::AssetId, T::ReserveData> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> ProvideAssetReserves<T::AssetId, T::ReserveData> for Pezpallet<T, I> {
/// Provide the configured reserves for asset `id`.
fn reserves(id: &T::AssetId) -> Vec<T::ReserveData> {
Reserves::<T, I>::get(id).into_inner()
+6 -6
View File
@@ -91,8 +91,8 @@ pub mod v1 {
pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let in_code_version = Pallet::<T>::in_code_storage_version();
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let in_code_version = Pezpallet::<T>::in_code_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
if on_chain_version == 0 && in_code_version == 1 {
let mut translated = 0u64;
Asset::<T>::translate::<
@@ -102,7 +102,7 @@ pub mod v1 {
translated.saturating_inc();
Some(old_value.migrate_to_v1())
});
in_code_version.put::<Pallet<T>>();
in_code_version.put::<Pezpallet<T>>();
log::info!(
target: LOG_TARGET,
"Upgraded {} pools, storage to version {:?}",
@@ -122,7 +122,7 @@ pub mod v1 {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
pezframe_support::ensure!(
Pallet::<T>::on_chain_storage_version() == 0,
Pezpallet::<T>::on_chain_storage_version() == 0,
"must upgrade linearly"
);
let prev_count = Asset::<T>::iter().count();
@@ -140,8 +140,8 @@ pub mod v1 {
"the asset count before and after the migration should be the same"
);
let in_code_version = Pallet::<T>::in_code_storage_version();
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let in_code_version = Pezpallet::<T>::in_code_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
pezframe_support::ensure!(in_code_version == 1, "must_upgrade");
ensure!(
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Test environment for Assets pallet.
//! Test environment for Assets pezpallet.
use super::*;
use crate as pezpallet_assets;
+4 -4
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for Assets pallet.
//! Tests for Assets pezpallet.
use super::*;
use crate::{mock::*, Error};
@@ -2049,8 +2049,8 @@ fn asset_create_and_destroy_is_reverted_if_callback_fails() {
#[test]
fn multiple_transfer_alls_work_ok() {
new_test_ext().execute_with(|| {
// Only run PoC when the system pallet is enabled, since the underlying bug is in the
// system pallet it won't work with BalancesAccountStore
// Only run PoC when the system pezpallet is enabled, since the underlying bug is in the
// system pezpallet it won't work with BalancesAccountStore
// Start with a balance of 100
Balances::force_set_balance(RuntimeOrigin::root(), 1, 100).unwrap();
// Emulate a sufficient, in reality this could be reached by transferring a sufficient
@@ -2160,7 +2160,7 @@ fn asset_id_cannot_be_reused() {
assert!(!Asset::<Test>::contains_key(0));
// Enable auto increment. Next asset id must be 5.
pallet::NextAssetId::<Test>::put(5);
pezpallet::NextAssetId::<Test>::put(5);
assert_noop!(Assets::create(RuntimeOrigin::signed(1), 0, 1, 1), Error::<Test>::BadAssetId);
assert_noop!(Assets::create(RuntimeOrigin::signed(1), 1, 1, 1), Error::<Test>::BadAssetId);
+1 -1
View File
@@ -70,7 +70,7 @@ type LeftFungibles<T> = fungibles::UnionOf<RightFungible<T>, T, ConvertToValue<L
///
/// By using this type, we can navigate through each branch of [`fungible::UnionOf`],
/// [`fungibles::UnionOf`], and [`ItemOf`] to access the underlying `fungibles::*`
/// implementation provided by the pallet.
/// implementation provided by the pezpallet.
type First<T> = fungibles::UnionOf<T, LeftFungibles<T>, ConvertToValue<RightAsset>, (), u64>;
#[test]
+3 -3
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Various basic types for use in the assets pallet.
//! Various basic types for use in the assets pezpallet.
use super::*;
use pezframe_support::{
@@ -183,7 +183,7 @@ pub struct AssetAccount<Balance, DepositBalance, Extra, AccountId> {
pub status: AccountStatus,
/// The reason for the existence of the account.
pub reason: ExistenceReason<DepositBalance, AccountId>,
/// Additional "sidecar" data, in case some other pallet wants to use this storage item.
/// Additional "sidecar" data, in case some other pezpallet wants to use this storage item.
pub extra: Extra,
}
@@ -319,7 +319,7 @@ pub enum ConversionError {
// Type alias for `pezframe_system`'s account id.
type AccountIdOf<T> = <T as pezframe_system::Config>::AccountId;
// This pallet's asset id and balance type.
// This pezpallet's asset id and balance type.
type AssetIdOf<T, I> = <T as Config<I>>::AssetId;
type AssetBalanceOf<T, I> = <T as Config<I>>::Balance;
// Generic fungible balance type.
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_assets
// --pezpallet=pezpallet_assets
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/assets/src/weights.rs
// --wasm-execution=compiled
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME atomic swap pallet"
description = "FRAME atomic swap pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-atomic-swap"
+26 -26
View File
@@ -17,15 +17,15 @@
//! # Atomic Swap
//!
//! A pallet for atomically sending funds.
//! A pezpallet for atomically sending funds.
//!
//! - [`Config`]
//! - [`Call`]
//! - [`Pallet`]
//! - [`Pezpallet`]
//!
//! ## Overview
//!
//! A pallet for atomically sending funds from an origin to a target. A proof
//! A pezpallet for atomically sending funds from an origin to a target. A proof
//! is used to allow the target to approve (claim) the swap. If the swap is not
//! claimed within a specified duration of time, the sender may cancel it.
//!
@@ -171,14 +171,14 @@ where
}
}
pub use pallet::*;
pub use pezpallet::*;
#[frame::pallet]
pub mod pallet {
#[frame::pezpallet]
pub mod pezpallet {
use super::*;
/// Atomic swap's pallet configuration trait.
#[pallet::config]
/// Atomic swap's pezpallet configuration trait.
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -195,14 +195,14 @@ pub mod pallet {
/// If B sees A is on a blockchain with larger proof length limit, then it should kindly
/// refuse to accept the atomic swap request if A generates the proof, and asks that B
/// generates the proof instead.
#[pallet::constant]
#[pezpallet::constant]
type ProofLimit: Get<u32>;
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::storage]
#[pezpallet::storage]
pub type PendingSwaps<T: Config> = StorageDoubleMap<
_,
Twox64Concat,
@@ -212,7 +212,7 @@ pub mod pallet {
PendingSwap<T>,
>;
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Swap already exists.
AlreadyExist,
@@ -232,9 +232,9 @@ pub mod pallet {
DurationNotPassed,
}
/// Event of atomic swap pallet.
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
/// Event of atomic swap pezpallet.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Swap created.
NewSwap { account: T::AccountId, proof: HashedProof, swap: PendingSwap<T> },
@@ -244,8 +244,8 @@ pub mod pallet {
SwapCancelled { account: T::AccountId, proof: HashedProof },
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Register a new atomic swap, declaring an intention to send funds from origin to target
/// on the current blockchain. The target can claim the fund using the revealed proof. If
/// the fund is not claimed after `duration` blocks, then the sender can cancel the swap.
@@ -258,8 +258,8 @@ pub mod pallet {
/// - `duration`: Locked duration of the atomic swap. For safety reasons, it is recommended
/// that the revealer uses a shorter duration than the counterparty, to prevent the
/// situation where the revealer reveals the proof too late around the end block.
#[pallet::call_index(0)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))]
pub fn create_swap(
origin: OriginFor<T>,
target: T::AccountId,
@@ -278,7 +278,7 @@ pub mod pallet {
let swap = PendingSwap {
source,
action,
end_block: pezframe_system::Pallet::<T>::block_number() + duration,
end_block: pezframe_system::Pezpallet::<T>::block_number() + duration,
};
PendingSwaps::<T>::insert(target.clone(), hashed_proof, swap.clone());
@@ -294,8 +294,8 @@ pub mod pallet {
/// - `proof`: Revealed proof of the claim.
/// - `action`: Action defined in the swap, it must match the entry in blockchain. Otherwise
/// the operation fails. This is used for weight calculation.
#[pallet::call_index(1)]
#[pallet::weight(
#[pezpallet::call_index(1)]
#[pezpallet::weight(
T::DbWeight::get().reads_writes(1, 1)
.saturating_add(action.weight())
.ref_time()
@@ -335,8 +335,8 @@ pub mod pallet {
///
/// - `target`: Target of the original atomic swap.
/// - `hashed_proof`: Hashed proof of the original atomic swap.
#[pallet::call_index(2)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1).ref_time().saturating_add(40_000_000))]
pub fn cancel_swap(
origin: OriginFor<T>,
target: T::AccountId,
@@ -347,7 +347,7 @@ pub mod pallet {
let swap = PendingSwaps::<T>::get(&target, hashed_proof).ok_or(Error::<T>::NotExist)?;
ensure!(swap.source == source, Error::<T>::SourceMismatch);
ensure!(
pezframe_system::Pallet::<T>::block_number() >= swap.end_block,
pezframe_system::Pezpallet::<T>::block_number() >= swap.end_block,
Error::<T>::DurationNotPassed,
);
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME AURA consensus pallet"
description = "FRAME AURA consensus pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-aura"
+2 -2
View File
@@ -1,7 +1,7 @@
# Aura Module
- [`aura::Config`](https://docs.rs/pezpallet-aura/latest/pallet_aura/pallet/trait.Config.html)
- [`Pallet`](https://docs.rs/pezpallet-aura/latest/pallet_aura/pallet/struct.Pallet.html)
- [`aura::Config`](https://docs.rs/pezpallet-aura/latest/pallet_aura/pezpallet/trait.Config.html)
- [`Pezpallet`](https://docs.rs/pezpallet-aura/latest/pallet_aura/pezpallet/struct.Pezpallet.html)
## Overview
+34 -34
View File
@@ -18,7 +18,7 @@
//! # Aura Module
//!
//! - [`Config`]
//! - [`Pallet`]
//! - [`Pezpallet`]
//!
//! ## Overview
//!
@@ -58,7 +58,7 @@ pub mod migrations;
mod mock;
mod tests;
pub use pallet::*;
pub use pezpallet::*;
const LOG_TARGET: &str = "runtime::aura";
@@ -66,7 +66,7 @@ const LOG_TARGET: &str = "runtime::aura";
/// [`pezpallet_timestamp::Config::MinimumPeriod`] by multiplying it by two, to ensure
/// that authors have the majority of their slot to author within.
///
/// This was the default behavior of the Aura pallet and may be used for
/// This was the default behavior of the Aura pezpallet and may be used for
/// backwards compatibility.
pub struct MinimumPeriodTimesTwo<T>(core::marker::PhantomData<T>);
@@ -76,13 +76,13 @@ impl<T: pezpallet_timestamp::Config> Get<T::Moment> for MinimumPeriodTimesTwo<T>
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezpallet_timestamp::Config + pezframe_system::Config {
/// The identifier type for an authority.
type AuthorityId: Member
@@ -90,7 +90,7 @@ pub mod pallet {
+ RuntimeAppPublic
+ MaybeSerializeDeserialize
+ MaxEncodedLen;
/// The maximum number of authorities that the pallet can hold.
/// The maximum number of authorities that the pezpallet can hold.
type MaxAuthorities: Get<u32>;
/// A way to check whether a given validator is disabled and should not be authoring blocks.
@@ -100,15 +100,15 @@ pub mod pallet {
/// Whether to allow block authors to create multiple blocks per slot.
///
/// If this is `true`, the pallet will allow slots to stay the same across sequential
/// blocks. If this is `false`, the pallet will require that subsequent blocks always have
/// If this is `true`, the pezpallet will allow slots to stay the same across sequential
/// blocks. If this is `false`, the pezpallet will require that subsequent blocks always have
/// higher slots than previous ones.
///
/// Regardless of the setting of this storage value, the pallet will always enforce the
/// Regardless of the setting of this storage value, the pezpallet will always enforce the
/// invariant that slots don't move backwards as the chain progresses.
///
/// The typical value for this should be 'false' unless this pallet is being augmented by
/// another pallet which enforces some limitation on the number of blocks authors can create
/// The typical value for this should be 'false' unless this pezpallet is being augmented by
/// another pezpallet which enforces some limitation on the number of blocks authors can create
/// using the same slot.
type AllowMultipleBlocksPerSlot: Get<bool>;
@@ -116,15 +116,15 @@ pub mod pallet {
/// The effective value of this type should not change while the chain is running.
///
/// For backwards compatibility either use [`MinimumPeriodTimesTwo`] or a const.
#[pallet::constant]
#[pezpallet::constant]
type SlotDuration: Get<<Self as pezpallet_timestamp::Config>::Moment>;
}
#[pallet::pallet]
pub struct Pallet<T>(core::marker::PhantomData<T>);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(core::marker::PhantomData<T>);
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
if let Some(new_slot) = Self::current_slot_from_digests() {
let current_slot = CurrentSlot::<T>::get();
@@ -163,31 +163,31 @@ pub mod pallet {
}
/// The current authority set.
#[pallet::storage]
#[pezpallet::storage]
pub type Authorities<T: Config> =
StorageValue<_, BoundedVec<T::AuthorityId, T::MaxAuthorities>, ValueQuery>;
/// The current slot of this block.
///
/// This will be set in `on_initialize`.
#[pallet::storage]
#[pezpallet::storage]
pub type CurrentSlot<T: Config> = StorageValue<_, Slot, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub authorities: Vec<T::AuthorityId>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Pallet::<T>::initialize_authorities(&self.authorities);
Pezpallet::<T>::initialize_authorities(&self.authorities);
}
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Change authorities.
///
/// The storage will be applied immediately.
@@ -207,7 +207,7 @@ impl<T: Config> Pallet<T> {
AURA_ENGINE_ID,
ConsensusLog::AuthoritiesChange(new.into_inner()).encode(),
);
<pezframe_system::Pallet<T>>::deposit_log(log);
<pezframe_system::Pezpallet<T>>::deposit_log(log);
}
/// Initial authorities.
@@ -231,7 +231,7 @@ impl<T: Config> Pallet<T> {
/// Get the current slot from the pre-runtime digests.
fn current_slot_from_digests() -> Option<Slot> {
let digest = pezframe_system::Pallet::<T>::digest();
let digest = pezframe_system::Pezpallet::<T>::digest();
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
for (id, mut data) in pre_runtime_digests {
if id == AURA_ENGINE_ID {
@@ -247,9 +247,9 @@ impl<T: Config> Pallet<T> {
T::SlotDuration::get()
}
/// Ensure the correctness of the state of this pallet.
/// Ensure the correctness of the state of this pezpallet.
///
/// This should be valid before or after each state transition of this pallet.
/// This should be valid before or after each state transition of this pezpallet.
///
/// # Invariants
///
@@ -297,11 +297,11 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pezpallet<T> {
type Public = T::AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
impl<T: Config> OneSessionHandler<T::AccountId> for Pezpallet<T> {
type Key = T::AuthorityId;
fn on_genesis_session<'a, I: 'a>(validators: I)
@@ -340,11 +340,11 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
ConsensusLog::<T::AuthorityId>::OnDisabled(i as AuthorityIndex).encode(),
);
<pezframe_system::Pallet<T>>::deposit_log(log);
<pezframe_system::Pezpallet<T>>::deposit_log(log);
}
}
impl<T: Config> FindAuthor<u32> for Pallet<T> {
impl<T: Config> FindAuthor<u32> for Pezpallet<T> {
fn find_author<'a, I>(digests: I) -> Option<u32>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
@@ -381,15 +381,15 @@ impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::AuthorityId>
}
/// Find the authority ID of the Aura authority who authored the current block.
pub type AuraAuthorId<T> = FindAccountFromAuthorIndex<T, Pallet<T>>;
pub type AuraAuthorId<T> = FindAccountFromAuthorIndex<T, Pezpallet<T>>;
impl<T: Config> IsMember<T::AuthorityId> for Pallet<T> {
impl<T: Config> IsMember<T::AuthorityId> for Pezpallet<T> {
fn is_member(authority_id: &T::AuthorityId) -> bool {
Authorities::<T>::get().iter().any(|id| id == authority_id)
}
}
impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
impl<T: Config> OnTimestampSet<T::Moment> for Pezpallet<T> {
fn on_timestamp_set(moment: T::Moment) {
let slot_duration = Self::slot_duration();
assert!(!slot_duration.is_zero(), "Aura slot duration cannot be zero.");
+1 -1
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Migrations for the AURA pallet.
//! Migrations for the AURA pezpallet.
use pezframe_support::{pezpallet_prelude::*, traits::Get, weights::Weight};
+3 -3
View File
@@ -19,7 +19,7 @@
#![cfg(test)]
use super::pallet;
use super::pezpallet;
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System, Test};
use codec::Encode;
use pezframe_support::traits::OnInitialize;
@@ -29,8 +29,8 @@ use pezsp_runtime::{Digest, DigestItem};
#[test]
fn initial_values() {
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
assert_eq!(pallet::CurrentSlot::<Test>::get(), 0u64);
assert_eq!(pallet::Authorities::<Test>::get().len(), Aura::authorities_len());
assert_eq!(pezpallet::CurrentSlot::<Test>::get(), 0u64);
assert_eq!(pezpallet::Authorities::<Test>::get().len(), Aura::authorities_len());
assert_eq!(Aura::authorities_len(), 4);
});
}
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet for authority discovery"
description = "FRAME pezpallet for authority discovery"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-authority-discovery"
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Authority discovery pallet.
//! # Authority discovery pezpallet.
//!
//! This pallet is used by the `client/authority-discovery` and by pezkuwi's teyrchain logic
//! This pezpallet is used by the `client/authority-discovery` and by pezkuwi's teyrchain logic
//! to retrieve the current and the next set of authorities.
// Ensure we're `no_std` when compiling for Wasm.
@@ -32,50 +32,50 @@ use pezframe_support::{
};
use pezsp_authority_discovery::AuthorityId;
pub use pallet::*;
pub use pezpallet::*;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
/// The pallet's config trait.
#[pezpallet::config]
/// The pezpallet's config trait.
pub trait Config: pezframe_system::Config + pezpallet_session::Config {
/// The maximum number of authorities that can be added.
type MaxAuthorities: Get<u32>;
}
#[pallet::storage]
#[pezpallet::storage]
/// Keys of the current authority set.
pub type Keys<T: Config> =
StorageValue<_, WeakBoundedVec<AuthorityId, T::MaxAuthorities>, ValueQuery>;
#[pallet::storage]
#[pezpallet::storage]
/// Keys of the next authority set.
pub type NextKeys<T: Config> =
StorageValue<_, WeakBoundedVec<AuthorityId, T::MaxAuthorities>, ValueQuery>;
#[derive(pezframe_support::DefaultNoBound)]
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub keys: Vec<AuthorityId>,
#[serde(skip)]
pub _config: core::marker::PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Pallet::<T>::initialize_keys(&self.keys)
Pezpallet::<T>::initialize_keys(&self.keys)
}
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Retrieve authority identifiers of the current and next authority set
/// sorted and deduplicated.
pub fn authorities() -> Vec<AuthorityId> {
@@ -113,11 +113,11 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pezpallet<T> {
type Public = AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
impl<T: Config> OneSessionHandler<T::AccountId> for Pezpallet<T> {
type Key = AuthorityId;
fn on_genesis_session<'a, I: 'a>(authorities: I)
@@ -255,7 +255,7 @@ mod tests {
#[test]
fn authorities_returns_current_and_next_authority_set() {
// The whole authority discovery pallet ignores account ids, but we still need them for
// The whole authority discovery pezpallet ignores account ids, but we still need them for
// `pezpallet_session::OneSessionHandler::on_new_session`, thus its safe to use the same value
// everywhere.
let account_id = AuthorityPair::from_seed_slice(vec![10; 32].as_ref()).unwrap().public();
+14 -14
View File
@@ -23,9 +23,9 @@
use pezframe_support::traits::FindAuthor;
pub use pallet::*;
pub use pezpallet::*;
/// An event handler for the authorship pallet. There is a dummy implementation
/// An event handler for the authorship pezpallet. There is a dummy implementation
/// for `()`, which does nothing.
#[impl_trait_for_tuples::impl_for_tuples(30)]
pub trait EventHandler<Author, BlockNumber> {
@@ -33,13 +33,13 @@ pub trait EventHandler<Author, BlockNumber> {
fn note_author(author: Author);
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Find the author of a block.
type FindAuthor: FindAuthor<Self::AccountId>;
@@ -47,11 +47,11 @@ pub mod pallet {
type EventHandler: EventHandler<Self::AccountId, BlockNumberFor<Self>>;
}
#[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 on_initialize(_: BlockNumberFor<T>) -> Weight {
if let Some(author) = Self::author() {
T::EventHandler::note_author(author);
@@ -66,13 +66,13 @@ pub mod pallet {
}
}
#[pallet::storage]
#[pallet::whitelist_storage]
#[pezpallet::storage]
#[pezpallet::whitelist_storage]
/// Author of current block.
pub(super) type Author<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Fetch the author of the block.
///
/// This is safe to invoke in `on_initialize` implementations, as well
@@ -83,7 +83,7 @@ impl<T: Config> Pallet<T> {
return Some(author);
}
let digest = <pezframe_system::Pallet<T>>::digest();
let digest = <pezframe_system::Pezpallet<T>>::digest();
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
T::FindAuthor::find_author(pre_runtime_digests).inspect(|a| {
<Author<T>>::put(&a);
@@ -117,7 +117,7 @@ mod tests {
type Block = Block;
}
impl pallet::Config for Test {
impl pezpallet::Config for Test {
type FindAuthor = AuthorGiven;
type EventHandler = ();
}
+2 -2
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Benchmarks for the BABE Pallet.
//! Benchmarks for the BABE Pezpallet.
#![cfg(feature = "runtime-benchmarks")]
@@ -71,5 +71,5 @@ mod benchmarks {
assert!(pezsp_consensus_babe::check_equivocation_proof::<Header>(equivocation_proof2));
}
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(3), crate::mock::Test,);
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(3), crate::mock::Test,);
}
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Default weights for the Babe Pallet
//! Default weights for the Babe Pezpallet
//! This file was not auto-generated.
use pezframe_support::weights::{
+7 -7
View File
@@ -25,12 +25,12 @@
//!
//! These can be used in an offchain context in order to submit equivocation
//! reporting extrinsics (from the client that's import BABE blocks).
//! And in a runtime context, so that the BABE pallet can validate the
//! And in a runtime context, so that the BABE pezpallet can validate the
//! equivocation proofs in the extrinsic and report the offences.
//!
//! IMPORTANT:
//! When using this module for enabling equivocation reporting it is required
//! that the `ValidateUnsigned` for the BABE pallet is used in the runtime
//! that the `ValidateUnsigned` for the BABE pezpallet is used in the runtime
//! definition.
use alloc::{boxed::Box, vec, vec::Vec};
@@ -52,7 +52,7 @@ use pezsp_staking::{
SessionIndex,
};
use crate::{Call, Config, Error, Pallet, LOG_TARGET};
use crate::{Call, Config, Error, Pezpallet, LOG_TARGET};
/// BABE equivocation offence report.
///
@@ -103,7 +103,7 @@ impl<Offender: Clone> Offence<Offender> for EquivocationOffence<Offender> {
/// `offchain::CreateTransactionBase`.
/// - On-chain validity checks and processing are mostly delegated to the user provided generic
/// types implementing `KeyOwnerProofSystem` and `ReportOffence` traits.
/// - Offence reporter for unsigned transactions is fetched via the the authorship pallet.
/// - Offence reporter for unsigned transactions is fetched via the the authorship pezpallet.
pub struct EquivocationReportSystem<T, R, P, L>(core::marker::PhantomData<(T, R, P, L)>);
impl<T, R, P, L>
@@ -164,7 +164,7 @@ where
evidence: (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof),
) -> Result<(), DispatchError> {
let (equivocation_proof, key_owner_proof) = evidence;
let reporter = reporter.or_else(|| <pezpallet_authorship::Pallet<T>>::author());
let reporter = reporter.or_else(|| <pezpallet_authorship::Pezpallet<T>>::author());
let offender = equivocation_proof.offender.clone();
let slot = equivocation_proof.slot;
@@ -181,7 +181,7 @@ where
// Check that the slot number is consistent with the session index
// in the key ownership proof (i.e. slot is for that epoch)
if Pallet::<T>::session_index_for_epoch(epoch_index) != session_index {
if Pezpallet::<T>::session_index_for_epoch(epoch_index) != session_index {
return Err(Error::<T>::InvalidKeyOwnershipProof.into());
}
@@ -202,7 +202,7 @@ where
/// It restricts calls to `report_equivocation_unsigned` to local calls (i.e. extrinsics generated
/// on this node) or that already in a block. This guarantees that only block authors can include
/// unsigned equivocation reports.
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
pub fn validate_unsigned(source: TransactionSource, call: &Call<T>) -> TransactionValidity {
if let Call::report_equivocation_unsigned { equivocation_proof, key_owner_proof } = call {
// discard equivocation report not coming from the local node
+62 -62
View File
@@ -70,7 +70,7 @@ pub use randomness::{
ParentBlockRandomness, RandomnessFromOneEpochAgo, RandomnessFromTwoEpochsAgo,
};
pub use pallet::*;
pub use pezpallet::*;
pub trait WeightInfo {
fn plan_config_change() -> Weight;
@@ -98,34 +98,34 @@ pub struct SameAuthoritiesForever;
impl EpochChangeTrigger for SameAuthoritiesForever {
fn trigger<T: Config>(now: BlockNumberFor<T>) {
if Pallet::<T>::should_epoch_change(now) {
if Pezpallet::<T>::should_epoch_change(now) {
let authorities = Authorities::<T>::get();
let next_authorities = authorities.clone();
Pallet::<T>::enact_epoch_change(authorities, next_authorities, None);
Pezpallet::<T>::enact_epoch_change(authorities, next_authorities, None);
}
}
}
const UNDER_CONSTRUCTION_SEGMENT_LENGTH: u32 = 256;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// The BABE Pallet
#[pallet::pallet]
pub struct Pallet<T>(_);
/// The BABE Pezpallet
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: pezpallet_timestamp::Config {
/// The amount of time, in slots, that each epoch should last.
/// NOTE: Currently it is not possible to change the epoch duration after
/// the chain has started. Attempting to do so will brick block production.
#[pallet::constant]
#[pezpallet::constant]
type EpochDuration: Get<u64>;
/// The expected average block time at which BABE should be creating
@@ -133,7 +133,7 @@ pub mod pallet {
/// what the expected average block time should be based on the slot
/// duration and the security parameter `c` (where `1 - c` represents
/// the probability of a slot being empty).
#[pallet::constant]
#[pezpallet::constant]
type ExpectedBlockTime: Get<Self::Moment>;
/// BABE requires some logic to be triggered on every block to query for whether an epoch
@@ -152,11 +152,11 @@ pub mod pallet {
type WeightInfo: WeightInfo;
/// Max number of authorities allowed
#[pallet::constant]
#[pezpallet::constant]
type MaxAuthorities: Get<u32>;
/// The maximum number of nominators for each validator.
#[pallet::constant]
#[pezpallet::constant]
type MaxNominators: Get<u32>;
/// The proof of key ownership, used for validating equivocation reports.
@@ -173,7 +173,7 @@ pub mod pallet {
>;
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// An equivocation proof provided as part of an equivocation report is invalid.
InvalidEquivocationProof,
@@ -186,11 +186,11 @@ pub mod pallet {
}
/// Current epoch index.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochIndex<T> = StorageValue<_, u64, ValueQuery>;
/// Current epoch authorities.
#[pallet::storage]
#[pezpallet::storage]
pub type Authorities<T: Config> = StorageValue<
_,
WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>,
@@ -199,11 +199,11 @@ pub mod pallet {
/// The slot at which the first epoch actually started. This is 0
/// until the first block of the chain.
#[pallet::storage]
#[pezpallet::storage]
pub type GenesisSlot<T> = StorageValue<_, Slot, ValueQuery>;
/// Current slot number.
#[pallet::storage]
#[pezpallet::storage]
pub type CurrentSlot<T> = StorageValue<_, Slot, ValueQuery>;
/// The epoch randomness for the *current* epoch.
@@ -219,19 +219,19 @@ pub mod pallet {
// NOTE: the following fields don't use the constants to define the
// array size because the metadata API currently doesn't resolve the
// variable to its underlying value.
#[pallet::storage]
#[pezpallet::storage]
pub type Randomness<T> = StorageValue<_, BabeRandomness, ValueQuery>;
/// Pending epoch configuration change that will be applied when the next epoch is enacted.
#[pallet::storage]
#[pezpallet::storage]
pub type PendingEpochConfigChange<T> = StorageValue<_, NextConfigDescriptor>;
/// Next epoch randomness.
#[pallet::storage]
#[pezpallet::storage]
pub type NextRandomness<T> = StorageValue<_, BabeRandomness, ValueQuery>;
/// Next epoch authorities.
#[pallet::storage]
#[pezpallet::storage]
pub type NextAuthorities<T: Config> = StorageValue<
_,
WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>,
@@ -247,11 +247,11 @@ pub mod pallet {
/// Once a segment reaches this length, we begin the next one.
/// We reset all segments and return to `0` at the beginning of every
/// epoch.
#[pallet::storage]
#[pezpallet::storage]
pub type SegmentIndex<T> = StorageValue<_, u32, ValueQuery>;
/// TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
#[pallet::storage]
#[pezpallet::storage]
pub type UnderConstruction<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -262,14 +262,14 @@ pub mod pallet {
/// Temporary value (cleared at block finalization) which is `Some`
/// if per-block initialization has already been called for current block.
#[pallet::storage]
#[pezpallet::storage]
pub type Initialized<T> = StorageValue<_, Option<PreDigest>>;
/// This field should always be populated during block processing unless
/// secondary plain slots are enabled (which don't contain a VRF output).
///
/// It is set in `on_finalize`, before it will contain the value from the last block.
#[pallet::storage]
#[pezpallet::storage]
pub type AuthorVrfRandomness<T> = StorageValue<_, Option<BabeRandomness>, ValueQuery>;
/// The block numbers when the last and current epoch have started, respectively `N-1` and
@@ -277,7 +277,7 @@ pub mod pallet {
/// NOTE: We track this is in order to annotate the block number when a given pool of
/// entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in
/// slots, which may be skipped, the block numbers may not line up with the slot numbers.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochStart<T: Config> =
StorageValue<_, (BlockNumberFor<T>, BlockNumberFor<T>), ValueQuery>;
@@ -286,17 +286,17 @@ pub mod pallet {
/// This entry is populated as part of block execution and is cleaned up
/// on block finalization. Querying this storage entry outside of block
/// execution context should always yield zero.
#[pallet::storage]
#[pezpallet::storage]
pub type Lateness<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
/// The configuration for the current epoch. Should never be `None` as it is initialized in
/// genesis.
#[pallet::storage]
#[pezpallet::storage]
pub type EpochConfig<T> = StorageValue<_, BabeEpochConfiguration>;
/// The configuration for the next epoch, `None` if the config will not change
/// (you can fallback to `EpochConfig` instead in that case).
#[pallet::storage]
#[pezpallet::storage]
pub type NextEpochConfig<T> = StorageValue<_, BabeEpochConfiguration>;
/// A list of the last 100 skipped epochs and the corresponding session index
@@ -307,12 +307,12 @@ pub mod pallet {
/// way to tie together sessions and epoch indices, i.e. we need to validate that
/// a validator was the owner of a given key on a given session, and what the
/// active epoch index was during that session.
#[pallet::storage]
#[pezpallet::storage]
pub type SkippedEpochs<T> =
StorageValue<_, BoundedVec<(u64, SessionIndex), ConstU32<100>>, ValueQuery>;
#[derive(pezframe_support::DefaultNoBound)]
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>,
pub epoch_config: BabeEpochConfiguration,
@@ -320,17 +320,17 @@ pub mod pallet {
pub _config: core::marker::PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
SegmentIndex::<T>::put(0);
Pallet::<T>::initialize_genesis_authorities(&self.authorities);
Pezpallet::<T>::initialize_genesis_authorities(&self.authorities);
EpochConfig::<T>::put(&self.epoch_config);
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
/// Initialization
fn on_initialize(now: BlockNumberFor<T>) -> Weight {
Self::initialize(now);
@@ -396,14 +396,14 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Report authority equivocation/misbehavior. This method will verify
/// the equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence will
/// be reported.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::report_equivocation(
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config>::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -429,8 +429,8 @@ pub mod pallet {
/// block authors will call it (validated in `ValidateUnsigned`), as such
/// if the block author is defined it will be defined as the equivocation
/// reporter.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::report_equivocation(
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as Config>::WeightInfo::report_equivocation(
key_owner_proof.validator_count(),
T::MaxNominators::get(),
))]
@@ -451,8 +451,8 @@ pub mod pallet {
/// the next call to `enact_epoch_change`. The config will be activated one epoch after.
/// Multiple calls to this method will replace any existing planned config change that had
/// not been enacted yet.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::plan_config_change())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(<T as Config>::WeightInfo::plan_config_change())]
pub fn plan_config_change(
origin: OriginFor<T>,
config: NextConfigDescriptor,
@@ -471,8 +471,8 @@ pub mod pallet {
}
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
#[pezpallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pezpallet<T> {
type Call = Call<T>;
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
Self::validate_unsigned(source, call)
@@ -484,7 +484,7 @@ pub mod pallet {
}
}
impl<T: Config> FindAuthor<u32> for Pallet<T> {
impl<T: Config> FindAuthor<u32> for Pezpallet<T> {
fn find_author<'a, I>(digests: I) -> Option<u32>
where
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
@@ -500,24 +500,24 @@ impl<T: Config> FindAuthor<u32> for Pallet<T> {
}
}
impl<T: Config> IsMember<AuthorityId> for Pallet<T> {
impl<T: Config> IsMember<AuthorityId> for Pezpallet<T> {
fn is_member(authority_id: &AuthorityId) -> bool {
Authorities::<T>::get().iter().any(|id| &id.0 == authority_id)
}
}
impl<T: Config> pezpallet_session::ShouldEndSession<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> pezpallet_session::ShouldEndSession<BlockNumberFor<T>> for Pezpallet<T> {
fn should_end_session(now: BlockNumberFor<T>) -> bool {
// it might be (and it is in current implementation) that session module is calling
// `should_end_session` from it's own `on_initialize` handler, in which case it's
// possible that babe's own `on_initialize` has not run yet, so let's ensure that we
// have initialized the pallet and updated the current slot.
// have initialized the pezpallet and updated the current slot.
Self::initialize(now);
Self::should_epoch_change(now)
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Public function to access epoch_index storage.
pub fn epoch_index() -> u64 {
EpochIndex::<T>::get()
@@ -690,7 +690,7 @@ impl<T: Config> Pallet<T> {
// Update the start blocks of the previous and new current epoch.
EpochStart::<T>::mutate(|(previous_epoch_start_block, current_epoch_start_block)| {
*previous_epoch_start_block = core::mem::take(current_epoch_start_block);
*current_epoch_start_block = <pezframe_system::Pallet<T>>::block_number();
*current_epoch_start_block = <pezframe_system::Pezpallet<T>>::block_number();
});
// After we update the current epoch, we signal the *next* epoch change
@@ -771,7 +771,7 @@ impl<T: Config> Pallet<T> {
fn deposit_consensus<U: Encode>(new: U) {
let log = DigestItem::Consensus(BABE_ENGINE_ID, new.encode());
<pezframe_system::Pallet<T>>::deposit_log(log)
<pezframe_system::Pezpallet<T>>::deposit_log(log)
}
fn deposit_randomness(randomness: &BabeRandomness) {
@@ -828,7 +828,7 @@ impl<T: Config> Pallet<T> {
}
let pre_digest =
<pezframe_system::Pallet<T>>::digest()
<pezframe_system::Pezpallet<T>>::digest()
.logs
.iter()
.filter_map(|s| s.as_pre_runtime())
@@ -927,7 +927,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
impl<T: Config> OnTimestampSet<T::Moment> for Pezpallet<T> {
fn on_timestamp_set(moment: T::Moment) {
let slot_duration = Self::slot_duration();
assert!(!slot_duration.is_zero(), "Babe slot duration cannot be zero.");
@@ -944,7 +944,7 @@ impl<T: Config> OnTimestampSet<T::Moment> for Pallet<T> {
}
impl<T: Config> pezframe_support::traits::EstimateNextSessionRotation<BlockNumberFor<T>>
for Pallet<T>
for Pezpallet<T>
{
fn average_session_length() -> BlockNumberFor<T> {
T::EpochDuration::get().saturated_into()
@@ -971,17 +971,17 @@ impl<T: Config> pezframe_support::traits::EstimateNextSessionRotation<BlockNumbe
}
}
impl<T: Config> pezframe_support::traits::Lateness<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> pezframe_support::traits::Lateness<BlockNumberFor<T>> for Pezpallet<T> {
fn lateness(&self) -> BlockNumberFor<T> {
Lateness::<T>::get()
}
}
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pallet<T> {
impl<T: Config> pezsp_runtime::BoundToRuntimeAppPublic for Pezpallet<T> {
type Public = AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T>
impl<T: Config> OneSessionHandler<T::AccountId> for Pezpallet<T>
where
T: pezpallet_session::Config,
{
@@ -1017,7 +1017,7 @@ where
),
);
let session_index = <pezpallet_session::Pallet<T>>::current_index();
let session_index = <pezpallet_session::Pezpallet<T>>::current_index();
Self::enact_epoch_change(bounded_authorities, next_bounded_authorities, Some(session_index))
}
@@ -1052,7 +1052,7 @@ pub mod migrations {
use super::*;
use pezframe_support::pezpallet_prelude::{StorageValue, ValueQuery};
/// Something that can return the storage prefix of the `Babe` pallet.
/// Something that can return the storage prefix of the `Babe` pezpallet.
pub trait BabePalletPrefix: Config {
fn pezpallet_prefix() -> &'static str;
}
+2 -2
View File
@@ -87,7 +87,7 @@ where
impl_opaque_keys! {
pub struct MockSessionKeys {
pub babe_authority: super::Pallet<Test>,
pub babe_authority: super::Pezpallet<Test>,
}
}
@@ -170,7 +170,7 @@ impl pezpallet_staking::Config for Test {
type BondingDuration = BondingDuration;
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type UnixTime = pezpallet_timestamp::Pallet<Test>;
type UnixTime = pezpallet_timestamp::Pezpallet<Test>;
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
+2 -2
View File
@@ -160,7 +160,7 @@ impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for ParentBlockR
T::Hashing::hash(&subject[..])
});
(random, <pezframe_system::Pallet<T>>::block_number().saturating_sub(One::one()))
(random, <pezframe_system::Pezpallet<T>>::block_number().saturating_sub(One::one()))
}
}
@@ -168,6 +168,6 @@ impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for ParentBlockR
impl<T: Config> RandomnessT<Option<T::Hash>, BlockNumberFor<T>> for CurrentBlockRandomness<T> {
fn random(subject: &[u8]) -> (Option<T::Hash>, BlockNumberFor<T>) {
let (random, _) = ParentBlockRandomness::<T>::random(subject);
(random, <pezframe_system::Pallet<T>>::block_number())
(random, <pezframe_system::Pezpallet<T>>::block_number())
}
}
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_babe
// --pezpallet=pezpallet_babe
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/babe/src/weights.rs
// --wasm-execution=compiled
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet bags list"
description = "FRAME pezpallet bags list"
documentation = "https://docs.rs/pezpallet-bags-list"
[lints]
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Fuzzer for FRAME pallet bags list"
description = "Fuzzer for FRAME pezpallet bags list"
publish = false
documentation = "https://docs.rs/pezpallet-bags-list-fuzzer"
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet bags list remote test"
description = "FRAME pezpallet bags list remote test"
publish = false
documentation = "https://docs.rs/pezpallet-bags-list-remote-tests"
@@ -73,7 +73,7 @@ pub fn display_and_check_bags<Runtime: RuntimeT<Instance1>>(
let vote_weight_thresh_as_unit = vote_weight_thresh_u64 as f64 / currency_unit as f64;
let pretty_thresh = format!("Threshold: {}. {}", vote_weight_thresh_as_unit, currency_name);
let bag = match pezpallet_bags_list::Pallet::<Runtime, Instance1>::list_bags_get(
let bag = match pezpallet_bags_list::Pezpallet::<Runtime, Instance1>::list_bags_get(
*vote_weight_thresh,
) {
Some(bag) => bag,
@@ -36,7 +36,7 @@ pub async fn execute<Runtime, Block>(
let mut ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: ws_url.to_string().into(),
pallets: vec![pezpallet_staking::Pallet::<Runtime>::name().to_string()],
pallets: vec![pezpallet_staking::Pezpallet::<Runtime>::name().to_string()],
..Default::default()
}))
.build()
@@ -52,7 +52,7 @@ pub async fn execute<Runtime, Block>(
// run the actual migration
let moved = <Runtime as pezpallet_staking::Config>::VoterList::unsafe_regenerate(
pezpallet_staking::Nominators::<Runtime>::iter().map(|(n, _)| n),
Box::new(|x| Some(pezpallet_staking::Pallet::<Runtime>::weight_of(x))),
Box::new(|x| Some(pezpallet_staking::Pezpallet::<Runtime>::weight_of(x))),
);
log::info!(target: LOG_TARGET, "Moved {} nominators", moved);
@@ -41,7 +41,7 @@ where
transport: ws_url.to_string().into(),
// NOTE: we don't scrape pezpallet-staking, this kinda ensures that the source of the data
// is bags-list.
pallets: vec![pezpallet_bags_list::Pallet::<Runtime, pezpallet_bags_list::Instance1>::name()
pallets: vec![pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
.to_string()],
at: None,
hashed_prefixes: vec![
@@ -75,7 +75,7 @@ where
// single page voter snapshot, thus page index == 0.
let voters =
<pezpallet_staking::Pallet<Runtime> as ElectionDataProvider>::electing_voters(bounds, Zero::zero())
<pezpallet_staking::Pezpallet<Runtime> as ElectionDataProvider>::electing_voters(bounds, Zero::zero())
.unwrap();
let mut voters_nominator_only = voters
@@ -36,7 +36,7 @@ pub async fn execute<Runtime, Block>(
let mut ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: ws_url.to_string().into(),
pallets: vec![pezpallet_bags_list::Pallet::<Runtime, pezpallet_bags_list::Instance1>::name()
pallets: vec![pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::name()
.to_string()],
hashed_prefixes: vec![
<pezpallet_staking::Bonded<Runtime>>::prefix_hash().to_vec(),
@@ -51,7 +51,7 @@ pub async fn execute<Runtime, Block>(
ext.execute_with(|| {
pezsp_core::crypto::set_default_ss58_version(Runtime::SS58Prefix::get().try_into().unwrap());
pezpallet_bags_list::Pallet::<Runtime, pezpallet_bags_list::Instance1>::do_try_state().unwrap();
pezpallet_bags_list::Pezpallet::<Runtime, pezpallet_bags_list::Instance1>::do_try_state().unwrap();
log::info!(target: crate::LOG_TARGET, "executed bags-list sanity check with no errors.");
+10 -10
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Benchmarks for the bags list pallet.
//! Benchmarks for the bags list pezpallet.
use super::*;
use crate::list::List;
@@ -58,7 +58,7 @@ benchmarks_instance_pallet! {
]
);
}: {
let voters = <Pallet<T, _> as SortedListProvider<T::AccountId>>::iter();
let voters = <Pezpallet<T, _> as SortedListProvider<T::AccountId>>::iter();
let len = voters.collect::<Vec<_>>().len();
assert_eq!(len as u32, n,"len is {}, expected {}", len, n);
}
@@ -93,7 +93,7 @@ benchmarks_instance_pallet! {
);
}: {
// this should only go into one of the bags
let voters = <Pallet<T, _> as SortedListProvider<T::AccountId>>::iter().take(n as usize / 4 );
let voters = <Pezpallet<T, _> as SortedListProvider<T::AccountId>>::iter().take(n as usize / 4 );
let len = voters.collect::<Vec<_>>().len();
assert_eq!(len as u32, n / 4,"len is {}, expected {}", len, n / 4);
}
@@ -127,7 +127,7 @@ benchmarks_instance_pallet! {
);
}: {
// this should only go into one of the bags
let mut iter_var = <Pallet<T, _> as SortedListProvider<T::AccountId>>::iter();
let mut iter_var = <Pezpallet<T, _> as SortedListProvider<T::AccountId>>::iter();
let mut voters = Vec::<T::AccountId>::with_capacity((n/4) as usize);
for _ in 0..(n/4) {
let next = iter_var.next().unwrap();
@@ -182,7 +182,7 @@ benchmarks_instance_pallet! {
// iter from someone in the 3rd bag, so this should touch ~75 nodes and 3 bags
let from: T::AccountId = account("node", 0, 2);
}: {
let voters = <Pallet<T, _> as SortedListProvider<T::AccountId>>::iter_from(&from).unwrap();
let voters = <Pezpallet<T, _> as SortedListProvider<T::AccountId>>::iter_from(&from).unwrap();
let len = voters.collect::<Vec<_>>().len();
assert_eq!(len as u32, 74,"len is {}, expected {}", len, 74);
}
@@ -386,7 +386,7 @@ benchmarks_instance_pallet! {
}
// Lock the list and simulate pending rebag insertions
<Pallet<T, I>>::lock();
<Pezpallet<T, I>>::lock();
// Create pending rebag entries (mix of valid and corrupted)
for i in 0..pending_count {
@@ -402,12 +402,12 @@ benchmarks_instance_pallet! {
T::ScoreProvider::set_score_of(&pending_node, pending_score);
}
let _ = <Pallet<T, I> as SortedListProvider<T::AccountId>>::on_insert(
let _ = <Pezpallet<T, I> as SortedListProvider<T::AccountId>>::on_insert(
pending_node, pending_score
);
}
<Pallet<T, I>>::unlock();
<Pezpallet<T, I>>::unlock();
// Now set new scores that will move nodes into higher bags
for i in 0..regular_count {
@@ -431,7 +431,7 @@ benchmarks_instance_pallet! {
}
: {
use pezframe_support::traits::Hooks;
<Pallet<T, I> as Hooks<_>>::on_idle(Default::default(), Weight::MAX);
<Pezpallet<T, I> as Hooks<_>>::on_idle(Default::default(), Weight::MAX);
}
verify {
// Verify all pending rebag entries were processed.
@@ -451,7 +451,7 @@ benchmarks_instance_pallet! {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
mock::ExtBuilder::default().skip_genesis_ids().build(),
mock::Runtime
);
+61 -61
View File
@@ -25,35 +25,35 @@
//! [github]:
//! https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//!
//! # Bags-List Pallet
//! # Bags-List Pezpallet
//!
//! An onchain implementation of a semi-sorted linked list, with permissionless sorting and update
//! operations.
//!
//! ## Pallet API
//! ## Pezpallet API
//!
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes,
//! including its configuration trait, dispatchables, storage items, events and errors.
//!
//! This pallet provides an implementation of
//! This pezpallet provides an implementation of
//! [`pezframe_election_provider_support::SortedListProvider`] and it can typically be used by another
//! pallet via this API.
//! pezpallet via this API.
//!
//! ## Overview
//!
//! This pallet splits `AccountId`s into different bags. Within a bag, these `AccountId`s are stored
//! as nodes in a linked-list manner. This pallet then provides iteration over all bags, which
//! This pezpallet splits `AccountId`s into different bags. Within a bag, these `AccountId`s are stored
//! as nodes in a linked-list manner. This pezpallet then provides iteration over all bags, which
//! basically allows an infinitely large list of items to be kept in a sorted manner.
//!
//! Each bags has a upper and lower range of scores, denoted by [`Config::BagThresholds`]. All nodes
//! within a bag must be within the range of the bag. If not, the permissionless [`Pallet::rebag`]
//! within a bag must be within the range of the bag. If not, the permissionless [`Pezpallet::rebag`]
//! can be used to move any node to the right bag.
//!
//! Once a `rebag` happens, the order within a node is still not enforced. To move a node to the
//! optimal position in a bag, the [`Pallet::put_in_front_of`] or [`Pallet::put_in_front_of_other`]
//! optimal position in a bag, the [`Pezpallet::put_in_front_of`] or [`Pezpallet::put_in_front_of_other`]
//! can be used.
//!
//! Additional reading, about how this pallet is used in the context of Pezkuwi's staking system:
//! Additional reading, about how this pezpallet is used in the context of Pezkuwi's staking system:
//! <https://pezkuwichain.io/blog/staking-update-september-2021/#bags-list-in-depth>
//!
//! ## Examples
@@ -62,7 +62,7 @@
//!
//! ## Low Level / Implementation Details
//!
//! The data structure exposed by this pallet aims to be optimized for:
//! The data structure exposed by this pezpallet aims to be optimized for:
//!
//! - insertions and removals.
//! - iteration over the top* N items by score, where the precise ordering of items doesn't
@@ -148,7 +148,7 @@ mod tests;
pub mod weights;
pub use list::{notional_bag_for, Bag, List, ListError, Node};
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
pub(crate) const LOG_TARGET: &str = "runtime::bags-list";
@@ -160,8 +160,8 @@ macro_rules! log {
log::$level!(
target: crate::LOG_TARGET,
concat!("[{:?}] 👜 [{}]", $patter),
<pezframe_system::Pallet<T>>::block_number(),
<crate::Pallet::<T, I> as pezframe_support::traits::PalletInfoAccess>::name()
<pezframe_system::Pezpallet<T>>::block_number(),
<crate::Pezpallet::<T, I> as pezframe_support::traits::PalletInfoAccess>::name()
$(, $values)*
)
};
@@ -169,23 +169,23 @@ macro_rules! log {
type AccountIdLookupOf<T> = <<T as pezframe_system::Config>::Lookup as StaticLookup>::Source;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T, I = ()>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: weights::WeightInfo;
/// Something that provides the scores of ids.
@@ -234,14 +234,14 @@ pub mod pallet {
///
/// In the event that this list ever changes, a copy of the old bags list must be retained.
/// With that `List::migrate` can be called, which will perform the appropriate migration.
#[pallet::constant]
#[pezpallet::constant]
type BagThresholds: Get<&'static [Self::Score]>;
/// Maximum number of accounts that may be re-bagged automatically in `on_idle`.
///
/// A value of `0` (obtained by configuring `type MaxAutoRebagPerBlock = ();`) disables
/// the feature.
#[pallet::constant]
#[pezpallet::constant]
type MaxAutoRebagPerBlock: Get<u32>;
/// The type used to dictate a node position relative to other nodes.
@@ -263,28 +263,28 @@ pub mod pallet {
/// A single node, within some bag.
///
/// Nodes store links forward and back within their respective bags.
#[pallet::storage]
#[pezpallet::storage]
pub type ListNodes<T: Config<I>, I: 'static = ()> =
CountedStorageMap<_, Twox64Concat, T::AccountId, list::Node<T, I>>;
/// A bag stored in storage.
///
/// Stores a `Bag` struct, which stores head and tail pointers to itself.
#[pallet::storage]
#[pezpallet::storage]
pub type ListBags<T: Config<I>, I: 'static = ()> =
StorageMap<_, Twox64Concat, T::Score, list::Bag<T, I>>;
/// Pointer that remembers the next node that will be auto-rebagged.
/// When `None`, the next scan will start from the list head again.
#[pallet::storage]
#[pezpallet::storage]
pub type NextNodeAutoRebagged<T: Config<I>, I: 'static = ()> =
StorageValue<_, T::AccountId, OptionQuery>;
/// Lock all updates to this pallet.
/// Lock all updates to this pezpallet.
///
/// If any nodes needs updating, removal or addition due to a temporary lock, the
/// [`Call::rebag`] can be used.
#[pallet::storage]
#[pezpallet::storage]
pub type Lock<T: Config<I>, I: 'static = ()> = StorageValue<_, (), OptionQuery>;
/// Accounts that failed to be inserted into the bags-list due to locking.
@@ -293,7 +293,7 @@ pub mod pallet {
/// Note: This storage is intentionally unbounded. The following factors make bounding
/// unnecessary:
/// 1. The storage usage is temporary - accounts are processed and removed in `on_idle`
/// 2. The pallet is only locked during snapshot generation, which is weight-limited
/// 2. The pezpallet is only locked during snapshot generation, which is weight-limited
/// 3. Processing happens at multiple accounts per block, clearing even large backlogs quickly
/// 4. An artificial limit could be exhausted by an attacker, preventing legitimate
/// auto-rebagging from putting accounts in the correct position
@@ -301,12 +301,12 @@ pub mod pallet {
/// We don't store the score here - it's always fetched from `ScoreProvider` when processing,
/// ensuring we use the most up-to-date score (accounts may have been slashed, rewarded, etc.
/// while waiting in the queue).
#[pallet::storage]
#[pezpallet::storage]
pub type PendingRebag<T: Config<I>, I: 'static = ()> =
CountedStorageMap<_, Twox64Concat, T::AccountId, ()>;
#[pallet::event]
#[pallet::generate_deposit(pub(crate) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(crate) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
/// Moved an account from one bag to another.
Rebagged { who: T::AccountId, from: T::Score, to: T::Score },
@@ -314,11 +314,11 @@ pub mod pallet {
ScoreUpdated { who: T::AccountId, new_score: T::Score },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// A error in the list interface implementation.
List(ListError),
/// Could not update a node, because the pallet is locked.
/// Could not update a node, because the pezpallet is locked.
Locked,
}
@@ -328,11 +328,11 @@ pub mod pallet {
}
}
#[pallet::view_functions]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::view_functions]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Get the current `score` of a given account.
///
/// Returns `(current, real_score)`, the former being the current score that this pallet is
/// Returns `(current, real_score)`, the former being the current score that this pezpallet is
/// aware of, which may or may not be up to date, and the latter being the real score, as
/// provided by
// [`Config::ScoreProvider`].
@@ -343,8 +343,8 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::call]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Declare that some `dislocated` account has, through rewards or penalties, sufficiently
/// changed its score that it should properly fall into a different bag than its current
/// one.
@@ -355,8 +355,8 @@ pub mod pallet {
/// `ScoreProvider`.
///
/// If `dislocated` does not exists, it returns an error.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::rebag_non_terminal().max(T::WeightInfo::rebag_terminal()))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::rebag_non_terminal().max(T::WeightInfo::rebag_terminal()))]
pub fn rebag(origin: OriginFor<T>, dislocated: AccountIdLookupOf<T>) -> DispatchResult {
ensure_signed(origin)?;
let dislocated = T::Lookup::lookup(dislocated)?;
@@ -377,8 +377,8 @@ pub mod pallet {
///
/// - both nodes are within the same bag,
/// - and `origin` has a greater `Score` than `lighter`.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::put_in_front_of())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::put_in_front_of())]
pub fn put_in_front_of(
origin: OriginFor<T>,
lighter: AccountIdLookupOf<T>,
@@ -391,11 +391,11 @@ pub mod pallet {
.map_err::<DispatchError, _>(Into::into)
}
/// Same as [`Pallet::put_in_front_of`], but it can be called by anyone.
/// Same as [`Pezpallet::put_in_front_of`], but it can be called by anyone.
///
/// Fee is paid by the origin under all circumstances.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::put_in_front_of())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::put_in_front_of())]
pub fn put_in_front_of_other(
origin: OriginFor<T>,
heavier: AccountIdLookupOf<T>,
@@ -411,8 +411,8 @@ pub mod pallet {
}
}
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
fn integrity_test() {
// to ensure they are strictly increasing, this also implies that duplicates are
// detected.
@@ -461,7 +461,7 @@ pub mod pallet {
}
if Self::ensure_unlocked().is_err() {
log!(debug, "Auto-rebag skipped: pallet is locked");
log!(debug, "Auto-rebag skipped: pezpallet is locked");
return meter.consumed();
}
@@ -515,7 +515,7 @@ pub mod pallet {
match Self::rebag_internal(&account) {
Err(Error::<T, I>::Locked) => {
defensive!("Pallet became locked during auto-rebag, stopping");
defensive!("Pezpallet became locked during auto-rebag, stopping");
break;
},
Err(e) => {
@@ -587,13 +587,13 @@ pub mod pallet {
}
#[cfg(any(test, feature = "try-runtime", feature = "fuzz"))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
pub fn do_try_state() -> Result<(), TryRuntimeError> {
List::<T, I>::do_try_state()
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Move an account from one bag to another, depositing an event on success.
///
/// If the account changed bags, returns `Ok(Some((from, to)))`.
@@ -631,7 +631,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
///
/// Returns `Ok(Some((from, to)))` if rebagging occurred, or `Ok(None)` if nothing changed.
fn rebag_internal(account: &T::AccountId) -> Result<Option<(T::Score, T::Score)>, Error<T, I>> {
// Ensure the pallet is not locked
// Ensure the pezpallet is not locked
Self::ensure_unlocked().map_err(|_| Error::<T, I>::Locked)?;
PendingRebag::<T, I>::remove(account);
@@ -644,7 +644,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
(true, Some(current_score)) => {
// The account exists and has a valid score, so try to rebag
log!(debug, "Attempting to rebag node {:?}", account);
Pallet::<T, I>::do_rebag(account, current_score)
Pezpallet::<T, I>::do_rebag(account, current_score)
.map_err::<Error<T, I>, _>(Into::into)
},
(false, Some(current_score)) => {
@@ -668,7 +668,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
}
impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pezpallet<T, I> {
type Error = ListError;
type Score = T::Score;
@@ -708,8 +708,8 @@ impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I>
}
fn on_insert(id: T::AccountId, score: T::Score) -> Result<(), ListError> {
Pallet::<T, I>::ensure_unlocked().inspect_err(|_| {
// Pallet is locked - store in PendingRebag for later processing
Pezpallet::<T, I>::ensure_unlocked().inspect_err(|_| {
// Pezpallet is locked - store in PendingRebag for later processing
// Only queue if auto-rebagging is enabled
if T::MaxAutoRebagPerBlock::get() > 0u32 {
PendingRebag::<T, I>::insert(&id, ());
@@ -719,8 +719,8 @@ impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I>
}
fn on_update(id: &T::AccountId, new_score: T::Score) -> Result<(), ListError> {
Pallet::<T, I>::ensure_unlocked()?;
Pallet::<T, I>::do_rebag(id, new_score).map(|_| ())
Pezpallet::<T, I>::ensure_unlocked()?;
Pezpallet::<T, I>::do_rebag(id, new_score).map(|_| ())
}
fn get_score(id: &T::AccountId) -> Result<T::Score, ListError> {
@@ -728,7 +728,7 @@ impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I>
}
fn on_remove(id: &T::AccountId) -> Result<(), ListError> {
Pallet::<T, I>::ensure_unlocked()?;
Pezpallet::<T, I>::ensure_unlocked()?;
List::<T, I>::remove(id)
}
@@ -778,8 +778,8 @@ impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I>
}
}
impl<T: Config<I>, I: 'static> ScoreProvider<T::AccountId> for Pallet<T, I> {
type Score = <Pallet<T, I> as SortedListProvider<T::AccountId>>::Score;
impl<T: Config<I>, I: 'static> ScoreProvider<T::AccountId> for Pezpallet<T, I> {
type Score = <Pezpallet<T, I> as SortedListProvider<T::AccountId>>::Score;
fn score(id: &T::AccountId) -> Option<T::Score> {
Node::<T, I>::get(id).map(|node| node.score())
@@ -127,7 +127,7 @@ impl<T: Config<I>, I: 'static> List<T, I> {
/// generated from scratch. Care needs to be taken to ensure
///
/// This may or may not need to be called at genesis as well, based on the configuration of the
/// pallet using this `List`.
/// pezpallet using this `List`.
///
/// Returns the number of ids migrated.
pub fn unsafe_regenerate(
@@ -373,7 +373,7 @@ mod list {
// not exposed as mutable in any sense.
#[pezframe_support::storage_alias]
type CounterForListNodes<T: Config> =
StorageValue<crate::Pallet<T>, u32, pezframe_support::pezpallet_prelude::ValueQuery>;
StorageValue<crate::Pezpallet<T>, u32, pezframe_support::pezpallet_prelude::ValueQuery>;
CounterForListNodes::<Runtime>::mutate(|counter| *counter += 1);
assert_eq!(crate::ListNodes::<Runtime>::count(), 5);
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! The migrations of this pallet.
//! The migrations of this pezpallet.
use codec::{Decode, Encode};
use core::marker::PhantomData;
@@ -42,7 +42,7 @@ impl<T: crate::Config<I>, I: 'static> OnRuntimeUpgrade for CheckCounterPrefix<T,
// The old explicit storage item.
#[pezframe_support::storage_alias]
type CounterForListNodes<T: crate::Config<I>, I: 'static> =
StorageValue<crate::Pallet<T, I>, u32>;
StorageValue<crate::Pezpallet<T, I>, u32>;
// ensure that a value exists in the counter struct.
ensure!(
@@ -76,7 +76,7 @@ mod old {
#[pezframe_support::storage_alias]
pub type ListNodes<T: crate::Config<I>, I: 'static> = StorageMap<
crate::Pallet<T, I>,
crate::Pezpallet<T, I>,
Twox64Concat,
<T as pezframe_system::Config>::AccountId,
PreScoreNode<T, I>,
@@ -84,7 +84,7 @@ mod old {
#[pezframe_support::storage_alias]
pub type CounterForListNodes<T: crate::Config<I>, I: 'static> =
StorageValue<crate::Pallet<T, I>, u32, ValueQuery>;
StorageValue<crate::Pezpallet<T, I>, u32, ValueQuery>;
}
/// A struct that migrates all bags lists to contain a score value.
+6 -6
View File
@@ -79,7 +79,7 @@ fn examples_work() {
})
}
mod pallet {
mod pezpallet {
use super::*;
#[test]
@@ -496,7 +496,7 @@ mod pallet {
// then
assert_noop!(
BagsList::put_in_front_of(RuntimeOrigin::signed(3), 2),
crate::pallet::Error::<Runtime>::List(ListError::NotHeavier)
crate::pezpallet::Error::<Runtime>::List(ListError::NotHeavier)
);
});
}
@@ -510,7 +510,7 @@ mod pallet {
// then
assert_noop!(
BagsList::put_in_front_of(RuntimeOrigin::signed(3), 4),
crate::pallet::Error::<Runtime>::List(ListError::NotHeavier)
crate::pezpallet::Error::<Runtime>::List(ListError::NotHeavier)
);
});
}
@@ -527,7 +527,7 @@ mod pallet {
// then
assert_noop!(
BagsList::put_in_front_of(RuntimeOrigin::signed(5), 4),
crate::pallet::Error::<Runtime>::List(ListError::NodeNotFound)
crate::pezpallet::Error::<Runtime>::List(ListError::NodeNotFound)
);
});
@@ -541,7 +541,7 @@ mod pallet {
// then
assert_noop!(
BagsList::put_in_front_of(RuntimeOrigin::signed(4), 5),
crate::pallet::Error::<Runtime>::List(ListError::NodeNotFound)
crate::pezpallet::Error::<Runtime>::List(ListError::NodeNotFound)
);
});
}
@@ -555,7 +555,7 @@ mod pallet {
// then
assert_noop!(
BagsList::put_in_front_of(RuntimeOrigin::signed(4), 1),
crate::pallet::Error::<Runtime>::List(ListError::NotInSameBag)
crate::pezpallet::Error::<Runtime>::List(ListError::NotInSameBag)
);
});
}
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_bags_list
// --pezpallet=pezpallet_bags_list
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/bags-list/src/weights.rs
// --wasm-execution=compiled
+1 -1
View File
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet to manage balances"
description = "FRAME pezpallet to manage balances"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-balances"
+4 -4
View File
@@ -2,9 +2,9 @@
The Balances module provides functionality for handling accounts and balances.
- [`Config`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pallet/trait.Config.html)
- [`Call`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pallet/enum.Call.html)
- [`Pallet`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pallet/struct.Pallet.html)
- [`Config`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pezpallet/trait.Config.html)
- [`Call`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pezpallet/enum.Call.html)
- [`Pezpallet`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pezpallet/struct.Pezpallet.html)
## Overview
@@ -113,7 +113,7 @@ fn update_ledger<T: Config>(
## Genesis config
The Balances module depends on the
[`GenesisConfig`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pallet/struct.GenesisConfig.html).
[`GenesisConfig`](https://docs.rs/pezpallet-balances/latest/pallet_balances/pezpallet/struct.GenesisConfig.html).
## Assumptions
@@ -15,12 +15,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Balances pallet benchmarking.
//! Balances pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use crate::Pallet as Balances;
use crate::Pezpallet as Balances;
use pezframe_benchmarking::v2::*;
use pezframe_system::RawOrigin;
@@ -283,15 +283,15 @@ mod benchmarks {
frozen: Zero::zero(),
flags: ExtraFlags::old_logic(),
};
pezframe_system::Pallet::<T>::inc_providers(&user);
pezframe_system::Pezpallet::<T>::inc_providers(&user);
assert!(T::AccountStore::try_mutate_exists(&user, |a| -> DispatchResult {
*a = Some(account);
Ok(())
})
.is_ok());
assert!(!Balances::<T, I>::account(&user).flags.is_new_logic());
assert_eq!(pezframe_system::Pallet::<T>::providers(&user), 1);
assert_eq!(pezframe_system::Pallet::<T>::consumers(&user), 0);
assert_eq!(pezframe_system::Pezpallet::<T>::providers(&user), 1);
assert_eq!(pezframe_system::Pezpallet::<T>::consumers(&user), 0);
user
})
.collect();
@@ -302,8 +302,8 @@ mod benchmarks {
for i in 0..u {
let user: T::AccountId = account("old_user", i, SEED);
assert!(Balances::<T, I>::account(&user).flags.is_new_logic());
assert_eq!(pezframe_system::Pallet::<T>::providers(&user), 1);
assert_eq!(pezframe_system::Pallet::<T>::consumers(&user), 1);
assert_eq!(pezframe_system::Pezpallet::<T>::providers(&user), 1);
assert_eq!(pezframe_system::Pezpallet::<T>::consumers(&user), 1);
}
}
@@ -214,7 +214,7 @@ mod imbalances {
fn drop(&mut self) {
if !self.0.is_zero() {
<super::TotalIssuance<T, I>>::mutate(|v| *v = v.saturating_add(self.0));
Pallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount: self.0 });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount: self.0 });
}
}
}
@@ -224,7 +224,7 @@ mod imbalances {
fn drop(&mut self) {
if !self.0.is_zero() {
<super::TotalIssuance<T, I>>::mutate(|v| *v = v.saturating_sub(self.0));
Pallet::<T, I>::deposit_event(Event::<T, I>::Rescinded { amount: self.0 });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::Rescinded { amount: self.0 });
}
}
}
@@ -234,7 +234,7 @@ mod imbalances {
{
fn handle(amount: T::Balance) {
<super::TotalIssuance<T, I>>::mutate(|v| *v = v.saturating_sub(amount));
Pallet::<T, I>::deposit_event(Event::<T, I>::BurnedDebt { amount });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::BurnedDebt { amount });
}
}
@@ -243,12 +243,12 @@ mod imbalances {
{
fn handle(amount: T::Balance) {
<super::TotalIssuance<T, I>>::mutate(|v| *v = v.saturating_add(amount));
Pallet::<T, I>::deposit_event(Event::<T, I>::MintedCredit { amount });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::MintedCredit { amount });
}
}
}
impl<T: Config<I>, I: 'static> Currency<T::AccountId> for Pallet<T, I>
impl<T: Config<I>, I: 'static> Currency<T::AccountId> for Pezpallet<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
@@ -301,7 +301,7 @@ where
});
});
Pallet::<T, I>::deposit_event(Event::<T, I>::Rescinded { amount });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::Rescinded { amount });
PositiveImbalance::new(amount)
}
@@ -319,7 +319,7 @@ where
})
});
Pallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount });
Pezpallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount });
NegativeImbalance::new(amount)
}
@@ -385,7 +385,7 @@ where
|account, _is_new| -> Result<(Self::NegativeImbalance, Self::Balance), DispatchError> {
// Best value is the most amount we can slash following liveness rules.
let ed = T::ExistentialDeposit::get();
let actual = match system::Pallet::<T>::can_dec_provider(who) {
let actual = match system::Pezpallet::<T>::can_dec_provider(who) {
true => value.min(account.free),
false => value.min(account.free.saturating_sub(ed)),
};
@@ -544,7 +544,7 @@ fn ensure_can_reserve<T: Config<I>, I: 'static>(
value: T::Balance,
check_existential_deposit: bool,
) -> DispatchResult {
let AccountData { free, .. } = Pallet::<T, I>::account(who);
let AccountData { free, .. } = Pezpallet::<T, I>::account(who);
// Early validation: Check sufficient free balance
let new_free_balance = free.checked_sub(&value).ok_or(Error::<T, I>::InsufficientBalance)?;
@@ -558,7 +558,7 @@ fn ensure_can_reserve<T: Config<I>, I: 'static>(
Ok(())
}
impl<T: Config<I>, I: 'static> ReservableCurrency<T::AccountId> for Pallet<T, I>
impl<T: Config<I>, I: 'static> ReservableCurrency<T::AccountId> for Pezpallet<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
@@ -689,7 +689,7 @@ where
}
}
impl<T: Config<I>, I: 'static> NamedReservableCurrency<T::AccountId> for Pallet<T, I>
impl<T: Config<I>, I: 'static> NamedReservableCurrency<T::AccountId> for Pezpallet<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
@@ -918,7 +918,7 @@ where
}
}
impl<T: Config<I>, I: 'static> LockableCurrency<T::AccountId> for Pallet<T, I>
impl<T: Config<I>, I: 'static> LockableCurrency<T::AccountId> for Pezpallet<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
@@ -988,7 +988,7 @@ where
}
}
impl<T: Config<I>, I: 'static> InspectLockableCurrency<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> InspectLockableCurrency<T::AccountId> for Pezpallet<T, I> {
fn balance_locked(id: LockIdentifier, who: &T::AccountId) -> Self::Balance {
Self::locks(who)
.into_iter()
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Implementation of `fungible` traits for Balances pallet.
//! Implementation of `fungible` traits for Balances pezpallet.
use super::*;
use pezframe_support::traits::{
tokens::{
@@ -26,7 +26,7 @@ use pezframe_support::traits::{
AccountTouch,
};
impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pezpallet<T, I> {
type Balance = T::Balance;
fn total_issuance() -> Self::Balance {
@@ -60,10 +60,10 @@ impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pallet<T, I>
if preservation == Preserve
// ..or we don't want the account to die and our provider ref is needed for it to live..
|| preservation == Protect && !a.free.is_zero() &&
pezframe_system::Pallet::<T>::providers(who) == 1
pezframe_system::Pezpallet::<T>::providers(who) == 1
// ..or we don't care about the account dying but our provider ref is required..
|| preservation == Expendable && !a.free.is_zero() &&
!pezframe_system::Pallet::<T>::can_dec_provider(who)
!pezframe_system::Pezpallet::<T>::can_dec_provider(who)
{
// ..then the ED needed..
untouchable = untouchable.max(T::ExistentialDeposit::get());
@@ -126,11 +126,11 @@ impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pallet<T, I>
// Provider restriction - total account balance cannot be reduced to zero if it cannot
// sustain the loss of a provider reference.
// NOTE: This assumes that the pallet is a provider (which is true). Is this ever changes,
// NOTE: This assumes that the pezpallet is a provider (which is true). Is this ever changes,
// then this will need to adapt accordingly.
let ed = T::ExistentialDeposit::get();
let success = if new_free_balance < ed {
if pezframe_system::Pallet::<T>::can_dec_provider(who) {
if pezframe_system::Pezpallet::<T>::can_dec_provider(who) {
WithdrawConsequence::ReducedToZero(new_free_balance)
} else {
return WithdrawConsequence::WouldDie;
@@ -150,7 +150,7 @@ impl<T: Config<I>, I: 'static> fungible::Inspect<T::AccountId> for Pallet<T, I>
}
}
impl<T: Config<I>, I: 'static> fungible::Unbalanced<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::Unbalanced<T::AccountId> for Pezpallet<T, I> {
fn handle_dust(dust: fungible::Dust<T::AccountId, Self>) {
T::DustRemoval::on_unbalanced(dust.into_credit());
}
@@ -188,7 +188,7 @@ impl<T: Config<I>, I: 'static> fungible::Unbalanced<T::AccountId> for Pallet<T,
}
}
impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pezpallet<T, I> {
fn done_mint_into(who: &T::AccountId, amount: Self::Balance) {
Self::deposit_event(Event::<T, I>::Minted { who: who.clone(), amount });
}
@@ -210,7 +210,7 @@ impl<T: Config<I>, I: 'static> fungible::Mutate<T::AccountId> for Pallet<T, I> {
}
}
impl<T: Config<I>, I: 'static> fungible::MutateHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::MutateHold<T::AccountId> for Pezpallet<T, I> {
fn done_hold(reason: &Self::Reason, who: &T::AccountId, amount: Self::Balance) {
Self::deposit_event(Event::<T, I>::Held { reason: *reason, who: who.clone(), amount });
}
@@ -253,7 +253,7 @@ impl<T: Config<I>, I: 'static> fungible::MutateHold<T::AccountId> for Pallet<T,
}
}
impl<T: Config<I>, I: 'static> fungible::InspectHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::InspectHold<T::AccountId> for Pezpallet<T, I> {
type Reason = T::RuntimeHoldReason;
fn total_balance_on_hold(who: &T::AccountId) -> T::Balance {
@@ -278,7 +278,7 @@ impl<T: Config<I>, I: 'static> fungible::InspectHold<T::AccountId> for Pallet<T,
.map_or_else(Zero::zero, |x| x.amount)
}
fn hold_available(reason: &Self::Reason, who: &T::AccountId) -> bool {
if pezframe_system::Pallet::<T>::providers(who) == 0 {
if pezframe_system::Pezpallet::<T>::providers(who) == 0 {
return false;
}
let holds = Holds::<T, I>::get(who);
@@ -289,7 +289,7 @@ impl<T: Config<I>, I: 'static> fungible::InspectHold<T::AccountId> for Pallet<T,
}
}
impl<T: Config<I>, I: 'static> fungible::UnbalancedHold<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::UnbalancedHold<T::AccountId> for Pezpallet<T, I> {
fn set_balance_on_hold(
reason: &Self::Reason,
who: &T::AccountId,
@@ -333,7 +333,7 @@ impl<T: Config<I>, I: 'static> fungible::UnbalancedHold<T::AccountId> for Pallet
}
}
impl<T: Config<I>, I: 'static> fungible::InspectFreeze<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::InspectFreeze<T::AccountId> for Pezpallet<T, I> {
type Id = T::FreezeIdentifier;
fn balance_frozen(id: &Self::Id, who: &T::AccountId) -> Self::Balance {
@@ -347,7 +347,7 @@ impl<T: Config<I>, I: 'static> fungible::InspectFreeze<T::AccountId> for Pallet<
}
}
impl<T: Config<I>, I: 'static> fungible::MutateFreeze<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::MutateFreeze<T::AccountId> for Pezpallet<T, I> {
fn set_freeze(id: &Self::Id, who: &T::AccountId, amount: Self::Balance) -> DispatchResult {
if amount.is_zero() {
return Self::thaw(id, who);
@@ -385,7 +385,7 @@ impl<T: Config<I>, I: 'static> fungible::MutateFreeze<T::AccountId> for Pallet<T
}
}
impl<T: Config<I>, I: 'static> fungible::Balanced<T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> fungible::Balanced<T::AccountId> for Pezpallet<T, I> {
type OnDropCredit = NegativeImbalance<T, I>;
type OnDropDebt = PositiveImbalance<T, I>;
@@ -405,17 +405,17 @@ impl<T: Config<I>, I: 'static> fungible::Balanced<T::AccountId> for Pallet<T, I>
}
}
impl<T: Config<I>, I: 'static> fungible::BalancedHold<T::AccountId> for Pallet<T, I> {}
impl<T: Config<I>, I: 'static> fungible::BalancedHold<T::AccountId> for Pezpallet<T, I> {}
impl<T: Config<I>, I: 'static>
fungible::hold::DoneSlash<T::RuntimeHoldReason, T::AccountId, T::Balance> for Pallet<T, I>
fungible::hold::DoneSlash<T::RuntimeHoldReason, T::AccountId, T::Balance> for Pezpallet<T, I>
{
fn done_slash(reason: &T::RuntimeHoldReason, who: &T::AccountId, amount: T::Balance) {
T::DoneSlashHandler::done_slash(reason, who, amount);
}
}
impl<T: Config<I>, I: 'static> AccountTouch<(), T::AccountId> for Pallet<T, I> {
impl<T: Config<I>, I: 'static> AccountTouch<(), T::AccountId> for Pezpallet<T, I> {
type Balance = T::Balance;
fn deposit_required(_: ()) -> Self::Balance {
Self::Balance::zero()
+92 -92
View File
@@ -15,21 +15,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Balances Pallet
//! # Balances Pezpallet
//!
//! The Balances pallet provides functionality for handling accounts and balances for a single
//! The Balances pezpallet provides functionality for handling accounts and balances for a single
//! token.
//!
//! It makes heavy use of concepts such as Holds and Freezes from the
//! [`pezframe_support::traits::fungible`] traits, therefore you should read and understand those docs
//! as a prerequisite to understanding this pallet.
//! as a prerequisite to understanding this pezpallet.
//!
//! Also see the [`frame_tokens`] reference docs for higher level information regarding the
//! place of this palet in FRAME.
//!
//! ## Overview
//!
//! The Balances pallet provides functions for:
//! The Balances pezpallet provides functions for:
//!
//! - Getting and setting free balances.
//! - Retrieving total, reserved and unreserved balances.
@@ -47,9 +47,9 @@
//!
//! ### Implementations
//!
//! The Balances pallet provides implementations for the following [`fungible`] traits. If these
//! The Balances pezpallet provides implementations for the following [`fungible`] traits. If these
//! traits provide the functionality that you need, then you should avoid tight coupling with the
//! Balances pallet.
//! Balances pezpallet.
//!
//! - [`fungible::Inspect`]
//! - [`fungible::Mutate`]
@@ -77,11 +77,11 @@
//!
//! ## Usage
//!
//! The following examples show how to use the Balances pallet in your custom pallet.
//! The following examples show how to use the Balances pezpallet in your custom pezpallet.
//!
//! ### Examples from the FRAME
//!
//! The Contract pallet uses the `Currency` trait to handle gas payment, and its types inherit from
//! The Contract pezpallet uses the `Currency` trait to handle gas payment, and its types inherit from
//! `Currency`:
//!
//! ```
@@ -96,7 +96,7 @@
//! # fn main() {}
//! ```
//!
//! The Staking pallet uses the `LockableCurrency` trait to lock a stash account's funds:
//! The Staking pezpallet uses the `LockableCurrency` trait to lock a stash account's funds:
//!
//! ```
//! use pezframe_support::traits::{WithdrawReasons, LockableCurrency};
@@ -128,14 +128,14 @@
//!
//! ## Genesis config
//!
//! The Balances pallet depends on the [`GenesisConfig`].
//! The Balances pezpallet depends on the [`GenesisConfig`].
//!
//! ## Assumptions
//!
//! * Total issued balanced of all accounts should be less than `Config::Balance::max_value()`.
//! * Existential Deposit is set to a value greater than zero.
//!
//! Note, you may find the Balances pallet still functions with an ED of zero when the
//! Note, you may find the Balances pezpallet still functions with an ED of zero when the
//! `insecure_zero_ed` cargo feature is enabled. However this is not a configuration which is
//! generally supported, nor will it be.
//!
@@ -191,7 +191,7 @@ pub use types::{
};
pub use weights::WeightInfo;
pub use pallet::*;
pub use pezpallet::*;
const LOG_TARGET: &str = "runtime::balances";
@@ -200,8 +200,8 @@ const DEFAULT_ADDRESS_URI: &str = "//Sender//{}";
type AccountIdLookupOf<T> = <<T as pezframe_system::Config>::Lookup as StaticLookup>::Source;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use codec::HasCompact;
use pezframe_support::{
@@ -210,7 +210,7 @@ pub mod pallet {
};
use pezframe_system::pezpallet_prelude::*;
pub type CreditOf<T, I> = Credit<<T as pezframe_system::Config>::AccountId, Pallet<T, I>>;
pub type CreditOf<T, I> = Credit<<T as pezframe_system::Config>::AccountId, Pezpallet<T, I>>;
/// Default implementations of [`DefaultConfig`], which can be used to implement [`Config`].
pub mod config_preludes {
@@ -248,23 +248,23 @@ pub mod pallet {
}
}
#[pallet::config(with_default)]
#[pezpallet::config(with_default)]
pub trait Config<I: 'static = ()>: pezframe_system::Config {
/// The overarching event type.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self, I>>
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The overarching hold reason.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeHoldReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount;
/// The overarching freeze reason.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type RuntimeFreezeReason: VariantCount;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
/// The balance of an account.
@@ -282,23 +282,23 @@ pub mod pallet {
+ FixedPointOperand;
/// Handler for the unbalanced reduction when removing a dust account.
#[pallet::no_default_bounds]
#[pezpallet::no_default_bounds]
type DustRemoval: OnUnbalanced<CreditOf<Self, I>>;
/// The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!
///
/// If you *really* need it to be zero, you can enable the feature `insecure_zero_ed` for
/// this pallet. However, you do so at your own risk: this will open up a major DoS vector.
/// this pezpallet. However, you do so at your own risk: this will open up a major DoS vector.
/// In case you have multiple sources of provider references, you may also get unexpected
/// behaviour if you set this to zero.
///
/// Bottom line: Do yourself a favour and make it at least one!
#[pallet::constant]
#[pallet::no_default_bounds]
#[pezpallet::constant]
#[pezpallet::no_default_bounds]
type ExistentialDeposit: Get<Self::Balance>;
/// The means of storing the balances of an account.
#[pallet::no_default]
#[pezpallet::no_default]
type AccountStore: StoredMap<Self::AccountId, AccountData<Self::Balance>>;
/// The ID type for reserves.
@@ -313,17 +313,17 @@ pub mod pallet {
/// Not strictly enforced, but used for weight estimation.
///
/// Use of locks is deprecated in favour of freezes. See `https://github.com/pezkuwichain/kurdistan-sdk/issues/40/`
#[pallet::constant]
#[pezpallet::constant]
type MaxLocks: Get<u32>;
/// The maximum number of named reserves that can exist on an account.
///
/// Use of reserves is deprecated in favour of holds. See `https://github.com/pezkuwichain/kurdistan-sdk/issues/40/`
#[pallet::constant]
#[pezpallet::constant]
type MaxReserves: Get<u32>;
/// The maximum number of individual freeze locks that can exist on an account at any time.
#[pallet::constant]
#[pezpallet::constant]
type MaxFreezes: Get<u32>;
/// Allows callbacks to other pallets so they can update their bookkeeping when a slash
@@ -339,12 +339,12 @@ pub mod pallet {
const STORAGE_VERSION: pezframe_support::traits::StorageVersion =
pezframe_support::traits::StorageVersion::new(1);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T, I = ()>(PhantomData<(T, I)>);
#[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<I>, I: 'static = ()> {
/// An account was created with some free balance.
Endowed { account: T::AccountId, free_balance: T::Balance },
@@ -437,7 +437,7 @@ pub mod pallet {
FailedToMutateAccount,
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// Vesting balance too high to send value.
VestingBalance,
@@ -466,17 +466,17 @@ pub mod pallet {
}
/// The total units issued in the system.
#[pallet::storage]
#[pallet::whitelist_storage]
#[pezpallet::storage]
#[pezpallet::whitelist_storage]
pub type TotalIssuance<T: Config<I>, I: 'static = ()> = StorageValue<_, T::Balance, ValueQuery>;
/// The total units of outstanding deactivated balance in the system.
#[pallet::storage]
#[pallet::whitelist_storage]
#[pezpallet::storage]
#[pezpallet::whitelist_storage]
pub type InactiveIssuance<T: Config<I>, I: 'static = ()> =
StorageValue<_, T::Balance, ValueQuery>;
/// The Balances pallet example of storing the balance of an account.
/// The Balances pezpallet example of storing the balance of an account.
///
/// # Example
///
@@ -486,7 +486,7 @@ pub mod pallet {
/// }
/// ```
///
/// You can also store the balance of an account in the `System` pallet.
/// You can also store the balance of an account in the `System` pezpallet.
///
/// # Example
///
@@ -496,11 +496,11 @@ pub mod pallet {
/// }
/// ```
///
/// But this comes with tradeoffs, storing account balances in the system pallet stores
/// But this comes with tradeoffs, storing account balances in the system pezpallet stores
/// `pezframe_system` data alongside the account data contrary to storing account balances in the
/// `Balances` pallet, which uses a `StorageMap` to store balances data only.
/// NOTE: This is only used in the case that this pallet is used to store balances.
#[pallet::storage]
/// `Balances` pezpallet, which uses a `StorageMap` to store balances data only.
/// NOTE: This is only used in the case that this pezpallet is used to store balances.
#[pezpallet::storage]
pub type Account<T: Config<I>, I: 'static = ()> =
StorageMap<_, Blake2_128Concat, T::AccountId, AccountData<T::Balance>, ValueQuery>;
@@ -508,7 +508,7 @@ pub mod pallet {
/// NOTE: Should only be accessed when setting, changing and freeing a lock.
///
/// Use of locks is deprecated in favour of freezes. See `https://github.com/pezkuwichain/kurdistan-sdk/issues/40/`
#[pallet::storage]
#[pezpallet::storage]
pub type Locks<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
@@ -520,7 +520,7 @@ pub mod pallet {
/// Named reserves on some account balances.
///
/// Use of reserves is deprecated in favour of holds. See `https://github.com/pezkuwichain/kurdistan-sdk/issues/40/`
#[pallet::storage]
#[pezpallet::storage]
pub type Reserves<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
@@ -530,7 +530,7 @@ pub mod pallet {
>;
/// Holds on account balances.
#[pallet::storage]
#[pezpallet::storage]
pub type Holds<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
@@ -543,7 +543,7 @@ pub mod pallet {
>;
/// Freeze locks on account balances.
#[pallet::storage]
#[pezpallet::storage]
pub type Freezes<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Blake2_128Concat,
@@ -552,7 +552,7 @@ pub mod pallet {
ValueQuery,
>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
pub balances: Vec<(T::AccountId, T::Balance)>,
/// Derived development accounts(Optional):
@@ -570,7 +570,7 @@ pub mod pallet {
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
let total = self.balances.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n);
@@ -600,22 +600,22 @@ pub mod pallet {
// Generate additional dev accounts.
if let Some((num_accounts, balance, ref derivation)) = self.dev_accounts {
// Using the provided derivation string or default to `"//Sender//{}`".
Pallet::<T, I>::derive_dev_account(
Pezpallet::<T, I>::derive_dev_account(
num_accounts,
balance,
derivation.as_deref().unwrap_or(DEFAULT_ADDRESS_URI),
);
}
for &(ref who, free) in self.balances.iter() {
pezframe_system::Pallet::<T>::inc_providers(who);
pezframe_system::Pezpallet::<T>::inc_providers(who);
assert!(T::AccountStore::insert(who, AccountData { free, ..Default::default() })
.is_ok());
}
}
}
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
fn integrity_test() {
#[cfg(not(feature = "insecure_zero_ed"))]
assert!(
@@ -636,8 +636,8 @@ pub mod pallet {
}
}
#[pallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::call(weight(<T as Config<I>>::WeightInfo))]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Transfer some liquid free balance to another account.
///
/// `transfer_allow_death` will set the `FreeBalance` of the sender and receiver.
@@ -645,11 +645,11 @@ pub mod pallet {
/// of the transfer, the account will be reaped.
///
/// The dispatch origin for this call must be `Signed` by the transactor.
#[pallet::call_index(0)]
#[pezpallet::call_index(0)]
pub fn transfer_allow_death(
origin: OriginFor<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] value: T::Balance,
#[pezpallet::compact] value: T::Balance,
) -> DispatchResult {
let source = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
@@ -659,12 +659,12 @@ pub mod pallet {
/// Exactly as `transfer_allow_death`, except the origin must be root and the source account
/// may be specified.
#[pallet::call_index(2)]
#[pezpallet::call_index(2)]
pub fn force_transfer(
origin: OriginFor<T>,
source: AccountIdLookupOf<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] value: T::Balance,
#[pezpallet::compact] value: T::Balance,
) -> DispatchResult {
ensure_root(origin)?;
let source = T::Lookup::lookup(source)?;
@@ -678,12 +678,12 @@ pub mod pallet {
///
/// 99% of the time you want [`transfer_allow_death`] instead.
///
/// [`transfer_allow_death`]: struct.Pallet.html#method.transfer
#[pallet::call_index(3)]
/// [`transfer_allow_death`]: struct.Pezpallet.html#method.transfer
#[pezpallet::call_index(3)]
pub fn transfer_keep_alive(
origin: OriginFor<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] value: T::Balance,
#[pezpallet::compact] value: T::Balance,
) -> DispatchResult {
let source = ensure_signed(origin)?;
let dest = T::Lookup::lookup(dest)?;
@@ -706,7 +706,7 @@ pub mod pallet {
/// of the funds the account has, causing the sender account to be killed (false), or
/// transfer everything except at least the existential deposit, which will guarantee to
/// keep the sender account alive (true).
#[pallet::call_index(4)]
#[pezpallet::call_index(4)]
pub fn transfer_all(
origin: OriginFor<T>,
dest: AccountIdLookupOf<T>,
@@ -732,7 +732,7 @@ pub mod pallet {
/// Unreserve some balance from a user by force.
///
/// Can only be called by ROOT.
#[pallet::call_index(5)]
#[pezpallet::call_index(5)]
pub fn force_unreserve(
origin: OriginFor<T>,
who: AccountIdLookupOf<T>,
@@ -752,8 +752,8 @@ pub mod pallet {
/// This will waive the transaction fee if at least all but 10% of the accounts needed to
/// be upgraded. (We let some not have to be upgraded just in order to allow for the
/// possibility of churn).
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::upgrade_accounts(who.len() as u32))]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::WeightInfo::upgrade_accounts(who.len() as u32))]
pub fn upgrade_accounts(
origin: OriginFor<T>,
who: Vec<T::AccountId>,
@@ -780,15 +780,15 @@ pub mod pallet {
/// Set the regular balance of a given account.
///
/// The dispatch origin for this call is `root`.
#[pallet::call_index(8)]
#[pallet::weight(
#[pezpallet::call_index(8)]
#[pezpallet::weight(
T::WeightInfo::force_set_balance_creating() // Creates a new account.
.max(T::WeightInfo::force_set_balance_killing()) // Kills an existing account.
)]
pub fn force_set_balance(
origin: OriginFor<T>,
who: AccountIdLookupOf<T>,
#[pallet::compact] new_free: T::Balance,
#[pezpallet::compact] new_free: T::Balance,
) -> DispatchResult {
ensure_root(origin)?;
let who = T::Lookup::lookup(who)?;
@@ -822,12 +822,12 @@ pub mod pallet {
///
/// # Example
#[doc = docify::embed!("./src/tests/dispatchable_tests.rs", force_adjust_total_issuance_example)]
#[pallet::call_index(9)]
#[pallet::weight(T::WeightInfo::force_adjust_total_issuance())]
#[pezpallet::call_index(9)]
#[pezpallet::weight(T::WeightInfo::force_adjust_total_issuance())]
pub fn force_adjust_total_issuance(
origin: OriginFor<T>,
direction: AdjustmentDirection,
#[pallet::compact] delta: T::Balance,
#[pezpallet::compact] delta: T::Balance,
) -> DispatchResult {
ensure_root(origin)?;
@@ -854,11 +854,11 @@ pub mod pallet {
///
/// Unlike sending funds to a _burn_ address, which merely makes the funds inaccessible,
/// this `burn` operation will reduce total issuance by the amount _burned_.
#[pallet::call_index(10)]
#[pallet::weight(if *keep_alive {T::WeightInfo::burn_allow_death() } else {T::WeightInfo::burn_keep_alive()})]
#[pezpallet::call_index(10)]
#[pezpallet::weight(if *keep_alive {T::WeightInfo::burn_allow_death() } else {T::WeightInfo::burn_keep_alive()})]
pub fn burn(
origin: OriginFor<T>,
#[pallet::compact] value: T::Balance,
#[pezpallet::compact] value: T::Balance,
keep_alive: bool,
) -> DispatchResult {
let source = ensure_signed(origin)?;
@@ -874,7 +874,7 @@ pub mod pallet {
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Public function to get the total issuance.
pub fn total_issuance() -> T::Balance {
TotalIssuance::<T, I>::get()
@@ -910,7 +910,7 @@ pub mod pallet {
}
a.flags.set_new_logic();
if !a.reserved.is_zero() && a.frozen.is_zero() {
if system::Pallet::<T>::providers(who) == 0 {
if system::Pezpallet::<T>::providers(who) == 0 {
// Gah!! We have no provider refs :(
// This shouldn't practically happen, but we need a failsafe anyway: let's give
// them enough for an ED.
@@ -920,9 +920,9 @@ pub mod pallet {
who
);
a.free = a.free.max(Self::ed());
system::Pallet::<T>::inc_providers(who);
system::Pezpallet::<T>::inc_providers(who);
}
let _ = system::Pallet::<T>::inc_consumers_without_limit(who).defensive();
let _ = system::Pezpallet::<T>::inc_consumers_without_limit(who).defensive();
}
// Should never fail - we're only setting a bit.
let _ = T::AccountStore::try_mutate_exists(who, |account| -> DispatchResult {
@@ -1045,7 +1045,7 @@ pub mod pallet {
/// Returns `false` otherwise.
#[cfg(feature = "insecure_zero_ed")]
fn have_providers_or_no_zero_ed(who: &T::AccountId) -> bool {
pezframe_system::Pallet::<T>::providers(who) > 0
pezframe_system::Pezpallet::<T>::providers(who) > 0
}
/// Mutate an account to some new value, or delete it entirely with `None`. Will enforce
@@ -1081,35 +1081,35 @@ pub mod pallet {
let does_consume = !account.reserved.is_zero() || !account.frozen.is_zero();
if !did_provide && does_provide {
pezframe_system::Pallet::<T>::inc_providers(who);
pezframe_system::Pezpallet::<T>::inc_providers(who);
}
if did_consume && !does_consume {
pezframe_system::Pallet::<T>::dec_consumers(who);
pezframe_system::Pezpallet::<T>::dec_consumers(who);
}
if !did_consume && does_consume {
if force_consumer_bump {
// If we are forcing a consumer bump, we do it without limit.
pezframe_system::Pallet::<T>::inc_consumers_without_limit(who)?;
pezframe_system::Pezpallet::<T>::inc_consumers_without_limit(who)?;
} else {
pezframe_system::Pallet::<T>::inc_consumers(who)?;
pezframe_system::Pezpallet::<T>::inc_consumers(who)?;
}
}
if does_consume && pezframe_system::Pallet::<T>::consumers(who) == 0 {
if does_consume && pezframe_system::Pezpallet::<T>::consumers(who) == 0 {
// NOTE: This is a failsafe and should not happen for normal accounts. A normal
// account should have gotten a consumer ref in `!did_consume && does_consume`
// at some point.
log::error!(target: LOG_TARGET, "Defensively bumping a consumer ref.");
pezframe_system::Pallet::<T>::inc_consumers(who)?;
pezframe_system::Pezpallet::<T>::inc_consumers(who)?;
}
if did_provide && !does_provide {
// This could reap the account so must go last.
pezframe_system::Pallet::<T>::dec_providers(who).inspect_err(|_| {
pezframe_system::Pezpallet::<T>::dec_providers(who).inspect_err(|_| {
// best-effort revert consumer change.
if did_consume && !does_consume {
let _ = pezframe_system::Pallet::<T>::inc_consumers(who).defensive();
let _ = pezframe_system::Pezpallet::<T>::inc_consumers(who).defensive();
}
if !did_consume && does_consume {
let _ = pezframe_system::Pallet::<T>::dec_consumers(who);
let _ = pezframe_system::Pezpallet::<T>::dec_consumers(who);
}
})?;
}
@@ -1151,7 +1151,7 @@ pub mod pallet {
});
}
if let Some(amount) = maybe_dust {
Pallet::<T, I>::deposit_event(Event::DustLost { account: who.clone(), amount });
Pezpallet::<T, I>::deposit_event(Event::DustLost { account: who.clone(), amount });
}
(result, maybe_dust)
})
@@ -1362,7 +1362,7 @@ pub mod pallet {
}
#[cfg(any(test, feature = "try-runtime"))]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
pub(crate) fn do_try_state(
_n: BlockNumberFor<T>,
) -> Result<(), pezsp_runtime::TryRuntimeError> {
@@ -22,23 +22,23 @@ use pezframe_support::{
};
fn migrate_v0_to_v1<T: Config<I>, I: 'static>(accounts: &[T::AccountId]) -> Weight {
let on_chain_version = Pallet::<T, I>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T, I>::on_chain_storage_version();
if on_chain_version == 0 {
let total = accounts
.iter()
.map(|a| Pallet::<T, I>::total_balance(a))
.map(|a| Pezpallet::<T, I>::total_balance(a))
.fold(T::Balance::zero(), |a, e| a.saturating_add(e));
Pallet::<T, I>::deactivate(total);
Pezpallet::<T, I>::deactivate(total);
// Remove the old `StorageVersion` type.
pezframe_support::storage::unhashed::kill(&pezframe_support::storage::storage_prefix(
Pallet::<T, I>::name().as_bytes(),
Pezpallet::<T, I>::name().as_bytes(),
"StorageVersion".as_bytes(),
));
// Set storage version to `1`.
StorageVersion::new(1).put::<Pallet<T, I>>();
StorageVersion::new(1).put::<Pezpallet<T, I>>();
log::info!(target: LOG_TARGET, "Storage to version 1");
T::DbWeight::get().reads_writes(2 + accounts.len() as u64, 3)
@@ -76,19 +76,19 @@ impl<T: Config<I>, A: Get<Vec<T::AccountId>>, I: 'static> OnRuntimeUpgrade
pub struct ResetInactive<T, I = ()>(PhantomData<(T, I)>);
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for ResetInactive<T, I> {
fn on_runtime_upgrade() -> Weight {
let on_chain_version = Pallet::<T, I>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T, I>::on_chain_storage_version();
if on_chain_version == 1 {
// Remove the old `StorageVersion` type.
pezframe_support::storage::unhashed::kill(&pezframe_support::storage::storage_prefix(
Pallet::<T, I>::name().as_bytes(),
Pezpallet::<T, I>::name().as_bytes(),
"StorageVersion".as_bytes(),
));
InactiveIssuance::<T, I>::kill();
// Set storage version to `0`.
StorageVersion::new(0).put::<Pallet<T, I>>();
StorageVersion::new(0).put::<Pezpallet<T, I>>();
log::info!(target: LOG_TARGET, "Storage to version 0");
T::DbWeight::get().reads_writes(1, 3)
@@ -176,7 +176,7 @@ fn transfer_all_works_4() {
fn set_balance_handles_killing_account() {
ExtBuilder::default().build_and_execute_with(|| {
let _ = Balances::mint_into(&1, 111);
assert_ok!(pezframe_system::Pallet::<Test>::inc_consumers(&1));
assert_ok!(pezframe_system::Pezpallet::<Test>::inc_consumers(&1));
assert_noop!(
Balances::force_set_balance(RuntimeOrigin::root(), 1, 0),
DispatchError::ConsumerRemaining,
@@ -579,8 +579,8 @@ fn sufficients_work_properly_with_reference_counting() {
.existential_deposit(1)
.monied(true)
.build_and_execute_with(|| {
// Only run PoC when the system pallet is enabled, since the underlying bug is in the
// system pallet it won't work with BalancesAccountStore
// Only run PoC when the system pezpallet is enabled, since the underlying bug is in the
// system pezpallet it won't work with BalancesAccountStore
if UseSystem::get() {
// Start with a balance of 100
<Balances as fungible::Mutate<_>>::set_balance(&1, 100);
@@ -20,7 +20,7 @@
#![cfg(test)]
use crate::{
self as pezpallet_balances, AccountData, Config, CreditOf, Error, Pallet, TotalIssuance,
self as pezpallet_balances, AccountData, Config, CreditOf, Error, Pezpallet, TotalIssuance,
DEFAULT_ADDRESS_URI,
};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
@@ -109,7 +109,7 @@ impl pezframe_system::Config for Test {
#[derive_impl(pezpallet_transaction_payment::config_preludes::TestDefaultConfig)]
impl pezpallet_transaction_payment::Config for Test {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = FungibleAdapter<Pallet<Test>, ()>;
type OnChargeTransaction = FungibleAdapter<Pezpallet<Test>, ()>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<u64>;
type LengthToFee = IdentityFee<u64>;
@@ -239,7 +239,7 @@ parameter_types! {
}
type BalancesAccountStore = StorageMapShim<super::Account<Test>, u64, super::AccountData<u64>>;
type SystemAccountStore = pezframe_system::Pallet<Test>;
type SystemAccountStore = pezframe_system::Pezpallet<Test>;
pub struct TestAccountStore;
impl StoredMap<u64, super::AccountData<u64>> for TestAccountStore {
@@ -336,9 +336,9 @@ pub fn ensure_ti_valid() {
continue;
}
// Check if we are using the system pallet or some other custom storage for accounts.
// Check if we are using the system pezpallet or some other custom storage for accounts.
if UseSystem::get() {
let data = pezframe_system::Pallet::<Test>::account(acc);
let data = pezframe_system::Pezpallet::<Test>::account(acc);
sum += data.data.total();
} else {
let data = crate::Account::<Test>::get(acc);
@@ -371,7 +371,7 @@ fn check_whitelist() {
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"));
}
/// This pallet runs tests twice, once with system as `type AccountStore` and once this pallet. This
/// This pezpallet runs tests twice, once with system as `type AccountStore` and once this pezpallet. This
/// function will return the right value based on the `UseSystem` flag.
pub(crate) fn get_test_account_data(who: AccountId) -> AccountData<Balance> {
if UseSystem::get() {
+3 -3
View File
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Types used in the pallet.
//! Types used in the pezpallet.
use crate::{Config, CreditOf, Event, Pallet};
use crate::{Config, CreditOf, Event, Pezpallet};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::ops::BitOr;
use pezframe_support::traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons};
@@ -190,7 +190,7 @@ pub struct DustCleaner<T: Config<I>, I: 'static = ()>(
impl<T: Config<I>, I: 'static> Drop for DustCleaner<T, I> {
fn drop(&mut self) {
if let Some((who, dust)) = self.0.take() {
Pallet::<T, I>::deposit_event(Event::DustLost { account: who, amount: dust.peek() });
Pezpallet::<T, I>::deposit_event(Event::DustLost { account: who, amount: dust.peek() });
T::DustRemoval::on_unbalanced(dust);
}
}
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_balances
// --pezpallet=pezpallet_balances
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/balances/src/weights.rs
// --wasm-execution=compiled
@@ -15,17 +15,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Beefy pallet benchmarking.
//! Beefy pezpallet benchmarking.
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use crate::Pallet as BeefyMmr;
use crate::Pezpallet as BeefyMmr;
use codec::Encode;
use pezframe_benchmarking::v2::*;
use pezframe_support::traits::Hooks;
use pezframe_system::{Config as SystemConfig, Pallet as System};
use pezpallet_mmr::{Nodes, Pallet as Mmr};
use pezframe_system::{Config as SystemConfig, Pezpallet as System};
use pezpallet_mmr::{Nodes, Pezpallet as Mmr};
use pezsp_consensus_beefy::Payload;
use pezsp_runtime::traits::One;
@@ -134,7 +134,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
crate::mock::new_test_ext(Default::default()),
crate::mock::Test
);
+25 -25
View File
@@ -18,12 +18,12 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
//! A BEEFY+MMR pallet combo.
//! A BEEFY+MMR pezpallet combo.
//!
//! While both BEEFY and Merkle Mountain Range (MMR) can be used separately,
//! these tools were designed to work together in unison.
//!
//! The pallet provides a standardized MMR Leaf format that can be used
//! The pezpallet provides a standardized MMR Leaf format that can be used
//! to bridge BEEFY+MMR-based networks (both standalone and Pezkuwi-like).
//!
//! The MMR leaf contains:
@@ -54,7 +54,7 @@ use pezsp_consensus_beefy::{
use pezframe_support::{crypto::ecdsa::ECDSAExt, pezpallet_prelude::Weight, traits::Get};
use pezframe_system::pezpallet_prelude::{BlockNumberFor, HeaderFor};
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
mod benchmarking;
@@ -79,7 +79,7 @@ where
<T as pezpallet_beefy::Config>::BeefyId,
>::MmrRoot(*root)),
);
pezframe_system::Pallet::<T>::deposit_log(digest);
pezframe_system::Pezpallet::<T>::deposit_log(digest);
}
}
@@ -99,20 +99,20 @@ impl Convert<pezsp_consensus_beefy::ecdsa_crypto::AuthorityId, Vec<u8>> for Beef
type MerkleRootOf<T> = <<T as pezpallet_mmr::Config>::Hashing as pezsp_runtime::traits::Hash>::Output;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
#![allow(missing_docs)]
use super::*;
use pezframe_support::pezpallet_prelude::*;
/// BEEFY-MMR pallet.
#[pallet::pallet]
pub struct Pallet<T>(_);
/// BEEFY-MMR pezpallet.
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// The module's configuration trait.
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: pezpallet_mmr::Config + pezpallet_beefy::Config {
/// Current leaf version.
///
@@ -138,19 +138,19 @@ pub mod pallet {
}
/// Details of current BEEFY authority set.
#[pallet::storage]
#[pezpallet::storage]
pub type BeefyAuthorities<T: Config> =
StorageValue<_, BeefyAuthoritySet<MerkleRootOf<T>>, ValueQuery>;
/// Details of next BEEFY authority set.
///
/// This storage entry is used as cache for calls to `update_beefy_next_authority_set`.
#[pallet::storage]
#[pezpallet::storage]
pub type BeefyNextAuthorities<T: Config> =
StorageValue<_, BeefyNextAuthoritySet<MerkleRootOf<T>>, ValueQuery>;
}
impl<T: Config> LeafDataProvider for Pallet<T> {
impl<T: Config> LeafDataProvider for Pezpallet<T> {
type LeafData = MmrLeaf<
BlockNumberFor<T>,
<T as pezframe_system::Config>::Hash,
@@ -168,24 +168,24 @@ impl<T: Config> LeafDataProvider for Pallet<T> {
}
}
impl<T> pezsp_consensus_beefy::OnNewValidatorSet<<T as pezpallet_beefy::Config>::BeefyId> for Pallet<T>
impl<T> pezsp_consensus_beefy::OnNewValidatorSet<<T as pezpallet_beefy::Config>::BeefyId> for Pezpallet<T>
where
T: pallet::Config,
T: pezpallet::Config,
{
/// Compute and cache BEEFY authority sets based on updated BEEFY validator sets.
fn on_new_validator_set(
current_set: &BeefyValidatorSet<<T as pezpallet_beefy::Config>::BeefyId>,
next_set: &BeefyValidatorSet<<T as pezpallet_beefy::Config>::BeefyId>,
) {
let current = Pallet::<T>::compute_authority_set(current_set);
let next = Pallet::<T>::compute_authority_set(next_set);
let current = Pezpallet::<T>::compute_authority_set(current_set);
let next = Pezpallet::<T>::compute_authority_set(next_set);
// cache the result
BeefyAuthorities::<T>::put(&current);
BeefyNextAuthorities::<T>::put(&next);
}
}
impl<T: Config> AncestryHelper<HeaderFor<T>> for Pallet<T>
impl<T: Config> AncestryHelper<HeaderFor<T>> for Pezpallet<T>
where
T: pezpallet_mmr::Config<Hashing = pezsp_consensus_beefy::MmrHashing>,
{
@@ -193,7 +193,7 @@ where
type ValidationContext = MerkleRootOf<T>;
fn is_proof_optimal(proof: &Self::Proof) -> bool {
let is_proof_optimal = pezpallet_mmr::Pallet::<T>::is_ancestry_proof_optimal(proof);
let is_proof_optimal = pezpallet_mmr::Pezpallet::<T>::is_ancestry_proof_optimal(proof);
// We don't check the proof size when running benchmarks, since we use mock proofs
// which would cause the test to fail.
@@ -206,7 +206,7 @@ where
fn extract_validation_context(header: HeaderFor<T>) -> Option<Self::ValidationContext> {
// Check if the provided header is canonical.
let expected_hash = pezframe_system::Pallet::<T>::block_hash(header.number());
let expected_hash = pezframe_system::Pezpallet::<T>::block_hash(header.number());
if expected_hash != header.hash() {
return None;
}
@@ -227,7 +227,7 @@ where
context: Self::ValidationContext,
) -> bool {
let commitment_leaf_count =
match pezpallet_mmr::Pallet::<T>::block_num_to_leaf_count(commitment.block_number) {
match pezpallet_mmr::Pezpallet::<T>::block_num_to_leaf_count(commitment.block_number) {
Ok(commitment_leaf_count) => commitment_leaf_count,
Err(_) => {
// We can't prove that the commitment is non-canonical if the
@@ -243,7 +243,7 @@ where
let canonical_mmr_root = context;
let canonical_prev_root =
match pezpallet_mmr::Pallet::<T>::verify_ancestry_proof(canonical_mmr_root, proof) {
match pezpallet_mmr::Pezpallet::<T>::verify_ancestry_proof(canonical_mmr_root, proof) {
Ok(canonical_prev_root) => canonical_prev_root,
Err(_) => {
// Can't prove that the commitment is non-canonical if the proof
@@ -282,7 +282,7 @@ where
}
}
impl<T: Config> AncestryHelperWeightInfo<HeaderFor<T>> for Pallet<T>
impl<T: Config> AncestryHelperWeightInfo<HeaderFor<T>> for Pezpallet<T>
where
T: pezpallet_mmr::Config<Hashing = pezsp_consensus_beefy::MmrHashing>,
{
@@ -310,7 +310,7 @@ where
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Return the currently active BEEFY authority set proof.
pub fn authority_set_proof() -> BeefyAuthoritySet<MerkleRootOf<T>> {
BeefyAuthorities::<T>::get()
+2 -2
View File
@@ -41,7 +41,7 @@ use pezsp_core::offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWork
impl_opaque_keys! {
pub struct MockSessionKeys {
pub dummy: pezpallet_beefy::Pallet<Test>,
pub dummy: pezpallet_beefy::Pezpallet<Test>,
}
}
@@ -194,7 +194,7 @@ pub fn new_test_ext_raw_authorities(authorities: Vec<(u64, BeefyId)>) -> TestExt
BasicExternalities::execute_with_storage(&mut t, || {
for (ref id, ..) in &session_keys {
pezframe_system::Pallet::<Test>::inc_providers(id);
pezframe_system::Pezpallet::<Test>::inc_providers(id);
}
});
+2 -2
View File
@@ -101,7 +101,7 @@ fn should_contain_valid_leaf_data() {
let mut ext = new_test_ext(vec![1, 2, 3, 4]);
let parent_hash = ext.execute_with(|| {
init_block(1, None);
pezframe_system::Pallet::<Test>::parent_hash()
pezframe_system::Pezpallet::<Test>::parent_hash()
});
let mmr_leaf = read_mmr_leaf(&mut ext, node_offchain_key(0, parent_hash));
@@ -126,7 +126,7 @@ fn should_contain_valid_leaf_data() {
// build second block on top
let parent_hash = ext.execute_with(|| {
init_block(2, None);
pezframe_system::Pallet::<Test>::parent_hash()
pezframe_system::Pezpallet::<Test>::parent_hash()
});
let mmr_leaf = read_mmr_leaf(&mut ext, node_offchain_key(1, parent_hash));
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_beefy_mmr
// --pezpallet=pezpallet_beefy_mmr
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/beefy-mmr/src/weights.rs
// --wasm-execution=compiled
+1 -1
View File
@@ -5,7 +5,7 @@ authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
repository.workspace = true
description = "BEEFY FRAME pallet"
description = "BEEFY FRAME pezpallet"
homepage.workspace = true
documentation = "https://docs.rs/pezpallet-beefy"

Some files were not shown because too many files have changed in this diff Show More