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:
@@ -4,7 +4,7 @@
|
||||
|
||||
use super::*;
|
||||
#[allow(unused)]
|
||||
use crate::Pallet as TokenWrapper;
|
||||
use crate::Pezpallet as TokenWrapper;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::traits::Currency;
|
||||
use pezframe_system::RawOrigin;
|
||||
@@ -16,10 +16,10 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn wrap() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let pezpallet_account = Pallet::<T>::account_id();
|
||||
let pezpallet_account = Pezpallet::<T>::account_id();
|
||||
let amount = 10_000u32.into();
|
||||
|
||||
// Fund both caller and pallet account
|
||||
// Fund both caller and pezpallet account
|
||||
let funding = <T::Currency as Currency<T::AccountId>>::minimum_balance()
|
||||
.saturating_mul(1000u32.into());
|
||||
|
||||
@@ -40,7 +40,7 @@ mod benchmarks {
|
||||
#[benchmark]
|
||||
fn unwrap() {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let pezpallet_account = Pallet::<T>::account_id();
|
||||
let pezpallet_account = Pezpallet::<T>::account_id();
|
||||
let amount = 10_000u32.into();
|
||||
|
||||
// Fund both accounts
|
||||
@@ -55,7 +55,7 @@ mod benchmarks {
|
||||
T::Assets::create(T::WrapperAssetId::get(), pezpallet_account.clone(), true, 1u32.into());
|
||||
|
||||
// Wrap first
|
||||
let _ = Pallet::<T>::wrap(RawOrigin::Signed(caller.clone()).into(), amount);
|
||||
let _ = Pezpallet::<T>::wrap(RawOrigin::Signed(caller.clone()).into(), amount);
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Signed(caller.clone()), amount);
|
||||
@@ -64,5 +64,5 @@ mod benchmarks {
|
||||
assert_eq!(T::Assets::balance(T::WrapperAssetId::get(), &caller), 0u32.into());
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Token Wrapper Pallet
|
||||
//! # Token Wrapper Pezpallet
|
||||
//!
|
||||
//! A pallet for wrapping native tokens (HEZ) into fungible assets (wHEZ)
|
||||
//! A pezpallet for wrapping native tokens (HEZ) into fungible assets (wHEZ)
|
||||
//! to enable DEX operations between native and asset tokens.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This pallet provides:
|
||||
//! This pezpallet provides:
|
||||
//! - `wrap`: Convert native HEZ to wHEZ (Asset ID 0)
|
||||
//! - `unwrap`: Convert wHEZ back to native HEZ
|
||||
//!
|
||||
//! The pallet maintains a 1:1 backing between HEZ and wHEZ.
|
||||
//! The pezpallet maintains a 1:1 backing between HEZ and wHEZ.
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
pub mod weights;
|
||||
|
||||
@@ -36,19 +36,19 @@ use pezframe_support::{
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
use pezsp_runtime::traits::{AccountIdConversion, Saturating, Zero};
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
|
||||
type BalanceOf<T> =
|
||||
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
/// Weight information for extrinsics in this pezpallet.
|
||||
type WeightInfo: crate::WeightInfo;
|
||||
|
||||
/// Native currency (HEZ)
|
||||
@@ -62,12 +62,12 @@ pub mod pallet {
|
||||
+ Mutate<Self::AccountId>
|
||||
+ Create<Self::AccountId>;
|
||||
|
||||
/// Pallet ID for the wrapper account
|
||||
#[pallet::constant]
|
||||
/// Pezpallet ID for the wrapper account
|
||||
#[pezpallet::constant]
|
||||
type PalletId: Get<PalletId>;
|
||||
|
||||
/// Asset ID for wrapped token (wHEZ)
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type WrapperAssetId: Get<Self::AssetId>;
|
||||
}
|
||||
|
||||
@@ -76,16 +76,16 @@ pub mod pallet {
|
||||
// ============================================================================
|
||||
|
||||
/// Total amount of native tokens locked in wrapper
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn total_locked)]
|
||||
#[pezpallet::storage]
|
||||
#[pezpallet::getter(fn total_locked)]
|
||||
pub type TotalLocked<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
|
||||
|
||||
// ============================================================================
|
||||
// EVENTS
|
||||
// ============================================================================
|
||||
|
||||
#[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> {
|
||||
/// Native token wrapped into asset token. [who, amount]
|
||||
Wrapped { who: T::AccountId, amount: BalanceOf<T> },
|
||||
@@ -97,7 +97,7 @@ pub mod pallet {
|
||||
// ERRORS
|
||||
// ============================================================================
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Insufficient balance for wrapping
|
||||
InsufficientBalance,
|
||||
@@ -117,22 +117,22 @@ pub mod pallet {
|
||||
// DISPATCHABLE FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Wrap native tokens (HEZ) into wrapped asset tokens (wHEZ)
|
||||
///
|
||||
/// - `amount`: The amount of native tokens to wrap
|
||||
///
|
||||
/// This will:
|
||||
/// 1. Transfer native tokens from user to pallet account (lock)
|
||||
/// 1. Transfer native tokens from user to pezpallet account (lock)
|
||||
/// 2. Mint equivalent amount of wrapped tokens to user
|
||||
///
|
||||
/// Emits `Wrapped` event.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::wrap())]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(T::WeightInfo::wrap())]
|
||||
pub fn wrap(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] amount: BalanceOf<T>,
|
||||
#[pezpallet::compact] amount: BalanceOf<T>,
|
||||
) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -142,7 +142,7 @@ pub mod pallet {
|
||||
// Check balance
|
||||
ensure!(T::Currency::free_balance(&who) >= amount, Error::<T>::InsufficientBalance);
|
||||
|
||||
// Transfer native tokens to pallet account (lock them)
|
||||
// Transfer native tokens to pezpallet account (lock them)
|
||||
T::Currency::transfer(
|
||||
&who,
|
||||
&Self::account_id(),
|
||||
@@ -173,11 +173,11 @@ pub mod pallet {
|
||||
/// 2. Transfer equivalent native tokens back to user (unlock)
|
||||
///
|
||||
/// Emits `Unwrapped` event.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::unwrap())]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(T::WeightInfo::unwrap())]
|
||||
pub fn unwrap(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] amount: BalanceOf<T>,
|
||||
#[pezpallet::compact] amount: BalanceOf<T>,
|
||||
) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -222,8 +222,8 @@ pub mod pallet {
|
||||
// HELPER FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Get the account ID of the pallet
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Get the account ID of the pezpallet
|
||||
pub fn account_id() -> T::AccountId {
|
||||
T::PalletId::get().into_account_truncating()
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ pub type AccountId = u64;
|
||||
pub type Balance = u128;
|
||||
pub type AssetId = u32;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
// Configure a mock runtime to test the pezpallet.
|
||||
construct_runtime!(
|
||||
pub enum Test {
|
||||
System: pezframe_system,
|
||||
@@ -149,7 +149,7 @@ pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
0, // Asset ID
|
||||
TokenWrapper::account_id(), // Owner = pallet account
|
||||
TokenWrapper::account_id(), // Owner = pezpallet account
|
||||
true, // is_sufficient
|
||||
1, // min_balance
|
||||
));
|
||||
|
||||
@@ -220,11 +220,11 @@ fn pezpallet_account_balance_consistency() {
|
||||
|
||||
let initial_pallet_balance = Balances::free_balance(&pezpallet_account);
|
||||
|
||||
// Wrap - pallet account should receive native tokens
|
||||
// Wrap - pezpallet account should receive native tokens
|
||||
assert_ok!(TokenWrapper::wrap(RuntimeOrigin::signed(user), amount));
|
||||
assert_eq!(Balances::free_balance(&pezpallet_account), initial_pallet_balance + amount);
|
||||
|
||||
// Unwrap - pallet account should release native tokens
|
||||
// Unwrap - pezpallet account should release native tokens
|
||||
assert_ok!(TokenWrapper::unwrap(RuntimeOrigin::signed(user), amount));
|
||||
assert_eq!(Balances::free_balance(&pezpallet_account), initial_pallet_balance);
|
||||
});
|
||||
@@ -245,7 +245,7 @@ fn wrap_unwrap_maintains_1_to_1_backing() {
|
||||
let pezpallet_account = TokenWrapper::account_id();
|
||||
let pezpallet_balance = Balances::free_balance(&pezpallet_account);
|
||||
|
||||
// Pallet should hold exactly the amount of wrapped tokens
|
||||
// Pezpallet should hold exactly the amount of wrapped tokens
|
||||
// (Note: may include existential deposit, so check >= total_wrapped)
|
||||
assert!(pezpallet_balance >= total_wrapped);
|
||||
assert_eq!(TokenWrapper::total_locked(), total_wrapped);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// ./target/release/frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --runtime
|
||||
// target/release/wbuild/asset-hub-pezkuwichain-runtime/asset_hub_pezkuwichain_runtime.compact.compressed.wasm
|
||||
// --pallets
|
||||
|
||||
Reference in New Issue
Block a user