style: Migrate to stable-only rustfmt configuration

- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml
- Removed features: imports_granularity, wrap_comments, comment_width,
  reorder_impl_items, spaces_around_ranges, binop_separator,
  match_arm_blocks, trailing_semicolon, trailing_comma
- Format all 898 affected files with stable rustfmt
- Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
2025-12-22 17:12:58 +03:00
parent 65b7f5e640
commit 4c8f281051
898 changed files with 8671 additions and 6432 deletions
+2 -2
View File
@@ -132,8 +132,8 @@ pub struct AssetsFrom<T>(PhantomData<T>);
impl<T: Get<Location>> ContainsPair<Asset, Location> for AssetsFrom<T> {
fn contains(asset: &Asset, origin: &Location) -> bool {
let loc = T::get();
&loc == origin &&
matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) }
&loc == origin
&& matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) }
if asset_loc.match_and_split(&loc).is_some())
}
}
+12 -8
View File
@@ -101,20 +101,24 @@ where
fn match_location(who: &VersionedLocatableAccount) -> Result<A::Type, ()> {
// only applicable for the local accounts
let account_id = match who {
VersionedLocatableAccount::V4 { location, account_id } if location.is_here() =>
&account_id.clone().try_into().map_err(|_| ())?,
VersionedLocatableAccount::V5 { location, account_id } if location.is_here() =>
account_id,
VersionedLocatableAccount::V4 { location, account_id } if location.is_here() => {
&account_id.clone().try_into().map_err(|_| ())?
},
VersionedLocatableAccount::V5 { location, account_id } if location.is_here() => {
account_id
},
_ => return Err(()),
};
C::convert_location(account_id).ok_or(())
}
fn match_asset(asset: &VersionedLocatableAsset) -> Result<xcm::v5::Location, ()> {
match asset {
VersionedLocatableAsset::V4 { location, asset_id } if location.is_here() =>
asset_id.clone().try_into().map(|a: xcm::v5::AssetId| a.0).map_err(|_| ()),
VersionedLocatableAsset::V5 { location, asset_id } if location.is_here() =>
Ok(asset_id.clone().0),
VersionedLocatableAsset::V4 { location, asset_id } if location.is_here() => {
asset_id.clone().try_into().map(|a: xcm::v5::AssetId| a.0).map_err(|_| ())
},
VersionedLocatableAsset::V5 { location, asset_id } if location.is_here() => {
Ok(asset_id.clone().0)
},
_ => Err(()),
}
}
@@ -70,12 +70,8 @@ mod imports {
LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub,
UsdtFromAssetHub as PenpalUsdtFromAssetHub,
},
PenpalAParaPezpallet,
PenpalAParaPezpallet as PenpalAPallet,
PenpalAssetOwner,
PenpalBParaPezpallet,
PenpalBParaPezpallet as PenpalBPallet,
ED as PENPAL_ED,
PenpalAParaPezpallet, PenpalAParaPezpallet as PenpalAPallet, PenpalAssetOwner,
PenpalBParaPezpallet, PenpalBParaPezpallet as PenpalBPallet, ED as PENPAL_ED,
},
pezkuwichain_emulated_chain::{
genesis::ED as PEZKUWICHAIN_ED,
@@ -85,8 +81,7 @@ mod imports {
xcm_config::UniversalLocation as PezkuwichainUniversalLocation, Dmp,
OriginCaller as PezkuwichainOriginCaller,
},
PezkuwichainRelayPezpallet,
PezkuwichainRelayPezpallet as PezkuwichainPallet,
PezkuwichainRelayPezpallet, PezkuwichainRelayPezpallet as PezkuwichainPallet,
},
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
AssetHubPezkuwichainParaReceiver as AssetHubPezkuwichainReceiver,
@@ -1067,8 +1067,8 @@ fn reserve_transfer_multiple_assets_from_asset_hub_to_para() {
// bought_execution`; `delivery_fees` might be paid from transfer or JIT, also
// `bought_execution` is unknown but should be non-zero
assert!(
receiver_system_native_assets_after <
receiver_system_native_assets_before + fee_amount_to_send
receiver_system_native_assets_after
< receiver_system_native_assets_before + fee_amount_to_send
);
// Sender's asset balance is reduced by exact amount
@@ -16,9 +16,7 @@
use crate::imports::*;
use emulated_integration_tests_common::accounts::{ALICE, BOB};
use pezframe_support::{
dispatch::RawOrigin,
pezsp_runtime::traits::Dispatchable,
traits::fungible::Inspect,
dispatch::RawOrigin, pezsp_runtime::traits::Dispatchable, traits::fungible::Inspect,
};
use pezkuwi_runtime_common::impls::VersionedLocatableAsset;
use pezkuwichain_runtime_constants::currency::GRAND;
@@ -171,98 +169,105 @@ mod disabled_usdt_treasury_test {
#[test]
fn create_and_claim_treasury_spend_in_usdt() {
const SPEND_AMOUNT: u128 = 10_000_000;
// treasury location from a sibling teyrchain.
let treasury_location: Location = Location::new(1, PalletInstance(18));
// treasury account on a sibling teyrchain.
let treasury_account =
ahr_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap();
let asset_hub_location = Location::new(0, Teyrchain(AssetHubPezkuwichain::para_id().into()));
let root = <Pezkuwichain as Chain>::RuntimeOrigin::root();
// asset kind to be spent from the treasury.
let asset_kind: VersionedLocatableAsset =
(asset_hub_location, AssetId((PalletInstance(50), GeneralIndex(USDT_ID.into())).into()))
const SPEND_AMOUNT: u128 = 10_000_000;
// treasury location from a sibling teyrchain.
let treasury_location: Location = Location::new(1, PalletInstance(18));
// treasury account on a sibling teyrchain.
let treasury_account =
ahr_xcm_config::LocationToAccountId::convert_location(&treasury_location).unwrap();
let asset_hub_location =
Location::new(0, Teyrchain(AssetHubPezkuwichain::para_id().into()));
let root = <Pezkuwichain as Chain>::RuntimeOrigin::root();
// asset kind to be spent from the treasury.
let asset_kind: VersionedLocatableAsset = (
asset_hub_location,
AssetId((PalletInstance(50), GeneralIndex(USDT_ID.into())).into()),
)
.into();
// treasury spend beneficiary.
let alice: AccountId = Pezkuwichain::account_id_of(ALICE);
let bob: AccountId = Pezkuwichain::account_id_of(BOB);
let bob_signed = <Pezkuwichain as Chain>::RuntimeOrigin::signed(bob.clone());
// treasury spend beneficiary.
let alice: AccountId = Pezkuwichain::account_id_of(ALICE);
let bob: AccountId = Pezkuwichain::account_id_of(BOB);
let bob_signed = <Pezkuwichain as Chain>::RuntimeOrigin::signed(bob.clone());
AssetHubPezkuwichain::execute_with(|| {
type Assets = <AssetHubPezkuwichain as AssetHubPezkuwichainPallet>::Assets;
AssetHubPezkuwichain::execute_with(|| {
type Assets = <AssetHubPezkuwichain as AssetHubPezkuwichainPallet>::Assets;
// USDT created at genesis, mint some assets to the treasury account.
assert_ok!(<Assets as Mutate<_>>::mint_into(USDT_ID, &treasury_account, SPEND_AMOUNT * 4));
// beneficiary has zero balance.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(USDT_ID, &alice,), 0u128,);
});
// USDT created at genesis, mint some assets to the treasury account.
assert_ok!(<Assets as Mutate<_>>::mint_into(
USDT_ID,
&treasury_account,
SPEND_AMOUNT * 4
));
// beneficiary has zero balance.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(USDT_ID, &alice,), 0u128,);
});
Pezkuwichain::execute_with(|| {
type RuntimeEvent = <Pezkuwichain as Chain>::RuntimeEvent;
type Treasury = <Pezkuwichain as PezkuwichainPallet>::Treasury;
type AssetRate = <Pezkuwichain as PezkuwichainPallet>::AssetRate;
Pezkuwichain::execute_with(|| {
type RuntimeEvent = <Pezkuwichain as Chain>::RuntimeEvent;
type Treasury = <Pezkuwichain as PezkuwichainPallet>::Treasury;
type AssetRate = <Pezkuwichain as PezkuwichainPallet>::AssetRate;
// create a conversion rate from `asset_kind` to the native currency.
assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into()));
// create a conversion rate from `asset_kind` to the native currency.
assert_ok!(AssetRate::create(root.clone(), Box::new(asset_kind.clone()), 2.into()));
Dmp::make_teyrchain_reachable(1000);
Dmp::make_teyrchain_reachable(1000);
// create and approve a treasury spend.
assert_ok!(Treasury::spend(
root,
Box::new(asset_kind),
SPEND_AMOUNT,
Box::new(Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
None,
));
// claim the spend.
assert_ok!(Treasury::payout(bob_signed.clone(), 0));
// create and approve a treasury spend.
assert_ok!(Treasury::spend(
root,
Box::new(asset_kind),
SPEND_AMOUNT,
Box::new(Location::new(0, Into::<[u8; 32]>::into(alice.clone())).into()),
None,
));
// claim the spend.
assert_ok!(Treasury::payout(bob_signed.clone(), 0));
assert_expected_events!(
Pezkuwichain,
vec![
RuntimeEvent::Treasury(pezpallet_treasury::Event::Paid { .. }) => {},
]
);
});
assert_expected_events!(
Pezkuwichain,
vec![
RuntimeEvent::Treasury(pezpallet_treasury::Event::Paid { .. }) => {},
]
);
});
AssetHubPezkuwichain::execute_with(|| {
type RuntimeEvent = <AssetHubPezkuwichain as Chain>::RuntimeEvent;
type Assets = <AssetHubPezkuwichain as AssetHubPezkuwichainPallet>::Assets;
AssetHubPezkuwichain::execute_with(|| {
type RuntimeEvent = <AssetHubPezkuwichain as Chain>::RuntimeEvent;
type Assets = <AssetHubPezkuwichain as AssetHubPezkuwichainPallet>::Assets;
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to Relay Chain treasury pezpallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubPezkuwichain,
vec![
RuntimeEvent::Assets(pezpallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => {
id: id == &USDT_ID,
from: from == &treasury_account,
to: to == &alice,
amount: amount == &SPEND_AMOUNT,
},
RuntimeEvent::TeyrchainSystem(pezcumulus_pezpallet_teyrchain_system::Event::UpwardMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pezpallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
// beneficiary received the assets from the treasury.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(USDT_ID, &alice,), SPEND_AMOUNT,);
});
// assert events triggered by xcm pay program
// 1. treasury asset transferred to spend beneficiary
// 2. response to Relay Chain treasury pezpallet instance sent back
// 3. XCM program completed
assert_expected_events!(
AssetHubPezkuwichain,
vec![
RuntimeEvent::Assets(pezpallet_assets::Event::Transferred { asset_id: id, from, to, amount }) => {
id: id == &USDT_ID,
from: from == &treasury_account,
to: to == &alice,
amount: amount == &SPEND_AMOUNT,
},
RuntimeEvent::TeyrchainSystem(pezcumulus_pezpallet_teyrchain_system::Event::UpwardMessageSent { .. }) => {},
RuntimeEvent::MessageQueue(pezpallet_message_queue::Event::Processed { success: true ,.. }) => {},
]
);
// beneficiary received the assets from the treasury.
assert_eq!(<Assets as FungiblesInspect<_>>::balance(USDT_ID, &alice,), SPEND_AMOUNT,);
});
Pezkuwichain::execute_with(|| {
type RuntimeEvent = <Pezkuwichain as Chain>::RuntimeEvent;
type Treasury = <Pezkuwichain as PezkuwichainPallet>::Treasury;
Pezkuwichain::execute_with(|| {
type RuntimeEvent = <Pezkuwichain as Chain>::RuntimeEvent;
type Treasury = <Pezkuwichain as PezkuwichainPallet>::Treasury;
// check the payment status to ensure the response from the AssetHub was received.
assert_ok!(Treasury::check_status(bob_signed, 0));
assert_expected_events!(
Pezkuwichain,
vec![
RuntimeEvent::Treasury(pezpallet_treasury::Event::SpendProcessed { .. }) => {},
]
);
});
// check the payment status to ensure the response from the AssetHub was received.
assert_ok!(Treasury::check_status(bob_signed, 0));
assert_expected_events!(
Pezkuwichain,
vec![
RuntimeEvent::Treasury(pezpallet_treasury::Event::SpendProcessed { .. }) => {},
]
);
});
}
}
@@ -279,10 +279,10 @@ fn multi_hop_works() {
);
assert_eq!(
receiver_assets_after,
receiver_assets_before + amount_to_send -
intermediate_execution_fees -
intermediate_delivery_fees_amount -
final_execution_fees
receiver_assets_before + amount_to_send
- intermediate_execution_fees
- intermediate_delivery_fees_amount
- final_execution_fees
);
}
@@ -65,8 +65,7 @@ mod imports {
ExistentialDeposit as AssetHubZagrosExistentialDeposit, ForeignAssetReserveData,
},
genesis::{AssetHubZagrosAssetOwner, ED as ASSET_HUB_ZAGROS_ED},
AssetHubZagrosParaPezpallet,
AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
AssetHubZagrosParaPezpallet, AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
},
collectives_zagros_emulated_chain::{
CollectivesZagrosParaPezpallet,
@@ -82,11 +81,8 @@ mod imports {
UniversalLocation as PenpalUniversalLocation,
UsdtFromAssetHub as PenpalUsdtFromAssetHub,
},
PenpalAParaPezpallet,
PenpalAParaPezpallet as PenpalAPallet,
PenpalAssetOwner,
PenpalBParaPezpallet,
PenpalBParaPezpallet as PenpalBPallet,
PenpalAParaPezpallet, PenpalAParaPezpallet as PenpalAPallet, PenpalAssetOwner,
PenpalBParaPezpallet, PenpalBParaPezpallet as PenpalBPallet,
},
pezbridge_hub_zagros_emulated_chain::{
pezbridge_hub_zagros_runtime::xcm_config::{self as bhw_xcm_config},
@@ -101,8 +97,7 @@ mod imports {
},
Dmp,
},
ZagrosRelayPezpallet,
ZagrosRelayPezpallet as ZagrosPallet,
ZagrosRelayPezpallet, ZagrosRelayPezpallet as ZagrosPallet,
},
AssetHubZagrosPara as AssetHubZagros, AssetHubZagrosParaReceiver as AssetHubZagrosReceiver,
AssetHubZagrosParaSender as AssetHubZagrosSender, BridgeHubZagrosPara as BridgeHubZagros,
@@ -1039,8 +1039,8 @@ fn reserve_transfer_multiple_assets_from_asset_hub_to_para() {
// bought_execution`; `delivery_fees` might be paid from transfer or JIT, also
// `bought_execution` is unknown but should be non-zero
assert!(
receiver_system_native_assets_after <
receiver_system_native_assets_before + fee_amount_to_send
receiver_system_native_assets_after
< receiver_system_native_assets_before + fee_amount_to_send
);
// Sender's asset balance is reduced by exact amount
@@ -327,10 +327,10 @@ fn multi_hop_works() {
);
assert_eq!(
receiver_assets_after,
receiver_assets_before + amount_to_send -
intermediate_execution_fees -
intermediate_delivery_fees_amount -
final_execution_fees
receiver_assets_before + amount_to_send
- intermediate_execution_fees
- intermediate_delivery_fees_amount
- final_execution_fees
);
}
@@ -27,8 +27,7 @@ mod imports {
pub(crate) use zagros_system_emulated_network::{
asset_hub_zagros_emulated_chain::{
asset_hub_zagros_runtime::xcm_config::LocationToAccountId as AssetHubLocationToAccountId,
genesis::ED as ASSET_HUB_ZAGROS_ED,
AssetHubZagrosParaPezpallet,
genesis::ED as ASSET_HUB_ZAGROS_ED, AssetHubZagrosParaPezpallet,
AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
},
collectives_zagros_emulated_chain::{
@@ -42,16 +41,12 @@ mod imports {
},
coretime_zagros_emulated_chain::CoretimeZagrosParaPezpallet,
people_zagros_emulated_chain::PeopleZagrosParaPezpallet,
pez_penpal_emulated_chain::{
PenpalAssetOwner,
PenpalBParaPezpallet,
},
pez_penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPezpallet},
pezbridge_hub_zagros_emulated_chain::BridgeHubZagrosParaPezpallet,
zagros_emulated_chain::{
genesis::ED as ZAGROS_ED,
zagros_runtime::{governance as zagros_governance, OriginCaller as ZagrosOriginCaller},
ZagrosRelayPezpallet,
ZagrosRelayPezpallet as ZagrosPallet,
ZagrosRelayPezpallet, ZagrosRelayPezpallet as ZagrosPallet,
},
AssetHubZagrosPara as AssetHubZagros, AssetHubZagrosParaReceiver as AssetHubZagrosReceiver,
AssetHubZagrosParaSender as AssetHubZagrosSender, BridgeHubZagrosPara as BridgeHubZagros,
@@ -30,14 +30,10 @@ mod imports {
asset_hub_pezkuwichain_emulated_chain::genesis::ED as ASSET_HUB_PEZKUWICHAIN_ED,
coretime_pezkuwichain_emulated_chain::{
coretime_pezkuwichain_runtime::ExistentialDeposit as CoretimePezkuwichainExistentialDeposit,
genesis::ED as CORETIME_PEZKUWICHAIN_ED,
CoretimePezkuwichainParaPezpallet,
genesis::ED as CORETIME_PEZKUWICHAIN_ED, CoretimePezkuwichainParaPezpallet,
CoretimePezkuwichainParaPezpallet as CoretimePezkuwichainPallet,
},
pezkuwichain_emulated_chain::{
genesis::ED as PEZKUWICHAIN_ED,
PezkuwichainRelayPezpallet,
},
pezkuwichain_emulated_chain::{genesis::ED as PEZKUWICHAIN_ED, PezkuwichainRelayPezpallet},
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
AssetHubPezkuwichainParaReceiver as AssetHubPezkuwichainReceiver,
AssetHubPezkuwichainParaSender as AssetHubPezkuwichainSender,
@@ -28,26 +28,18 @@ mod imports {
};
pub(crate) use zagros_system_emulated_network::{
asset_hub_zagros_emulated_chain::{
genesis::ED as ASSET_HUB_ZAGROS_ED,
AssetHubZagrosParaPezpallet,
genesis::ED as ASSET_HUB_ZAGROS_ED, AssetHubZagrosParaPezpallet,
},
collectives_zagros_emulated_chain::CollectivesZagrosParaPezpallet,
coretime_zagros_emulated_chain::{
self, coretime_zagros_runtime::ExistentialDeposit as CoretimeZagrosExistentialDeposit,
genesis::ED as CORETIME_ZAGROS_ED,
CoretimeZagrosParaPezpallet,
genesis::ED as CORETIME_ZAGROS_ED, CoretimeZagrosParaPezpallet,
CoretimeZagrosParaPezpallet as CoretimeZagrosPallet,
},
people_zagros_emulated_chain::PeopleZagrosParaPezpallet,
pez_penpal_emulated_chain::{
PenpalAssetOwner,
PenpalBParaPezpallet,
},
pez_penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPezpallet},
pezbridge_hub_zagros_emulated_chain::BridgeHubZagrosParaPezpallet,
zagros_emulated_chain::{
genesis::ED as ZAGROS_ED,
ZagrosRelayPezpallet,
},
zagros_emulated_chain::{genesis::ED as ZAGROS_ED, ZagrosRelayPezpallet},
AssetHubZagrosPara as AssetHubZagros, AssetHubZagrosParaReceiver as AssetHubZagrosReceiver,
AssetHubZagrosParaSender as AssetHubZagrosSender, BridgeHubZagrosPara as BridgeHubZagros,
CollectivesZagrosPara as CollectivesZagros, CoretimeZagrosPara as CoretimeZagros,
@@ -35,10 +35,7 @@ mod imports {
PeoplePezkuwichainParaPezpallet,
PeoplePezkuwichainParaPezpallet as PeoplePezkuwichainPallet,
},
pezkuwichain_emulated_chain::{
genesis::ED as PEZKUWICHAIN_ED,
PezkuwichainRelayPezpallet,
},
pezkuwichain_emulated_chain::{genesis::ED as PEZKUWICHAIN_ED, PezkuwichainRelayPezpallet},
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
AssetHubPezkuwichainParaReceiver as AssetHubPezkuwichainReceiver,
PeoplePezkuwichainPara as PeoplePezkuwichain,
@@ -28,8 +28,7 @@ mod imports {
pub(crate) use zagros_system_emulated_network::{
self,
asset_hub_zagros_emulated_chain::{
AssetHubZagrosParaPezpallet,
AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
AssetHubZagrosParaPezpallet, AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
},
collectives_zagros_emulated_chain::CollectivesZagrosParaPezpallet,
coretime_zagros_emulated_chain::CoretimeZagrosParaPezpallet,
@@ -38,18 +37,11 @@ mod imports {
self, xcm_config::XcmConfig as PeopleZagrosXcmConfig,
ExistentialDeposit as PeopleZagrosExistentialDeposit,
},
PeopleZagrosParaPezpallet,
PeopleZagrosParaPezpallet as PeopleZagrosPallet,
},
pez_penpal_emulated_chain::{
PenpalAssetOwner,
PenpalBParaPezpallet,
PeopleZagrosParaPezpallet, PeopleZagrosParaPezpallet as PeopleZagrosPallet,
},
pez_penpal_emulated_chain::{PenpalAssetOwner, PenpalBParaPezpallet},
pezbridge_hub_zagros_emulated_chain::BridgeHubZagrosParaPezpallet,
zagros_emulated_chain::{
genesis::ED as ZAGROS_ED,
ZagrosRelayPezpallet,
},
zagros_emulated_chain::{genesis::ED as ZAGROS_ED, ZagrosRelayPezpallet},
AssetHubZagrosPara as AssetHubZagros, AssetHubZagrosParaReceiver as AssetHubZagrosReceiver,
BridgeHubZagrosPara as BridgeHubZagros, CollectivesZagrosPara as CollectivesZagros,
CoretimeZagrosPara as CoretimeZagros, PenpalBPara as PenpalB,
@@ -58,16 +58,14 @@ mod imports {
CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub,
UniversalLocation as PenpalUniversalLocation,
},
PenpalAParaPezpallet as PenpalAPallet,
PenpalAssetOwner,
PenpalAParaPezpallet as PenpalAPallet, PenpalAssetOwner,
},
pezbridge_hub_pezkuwichain_emulated_chain::{
genesis::ED as BRIDGE_HUB_PEZKUWICHAIN_ED, BridgeHubPezkuwichainExistentialDeposit,
BridgeHubPezkuwichainParaPezpallet,
},
pezkuwichain_emulated_chain::{
genesis::ED as PEZKUWICHAIN_ED,
PezkuwichainRelayPezpallet,
genesis::ED as PEZKUWICHAIN_ED, PezkuwichainRelayPezpallet,
PezkuwichainRelayPezpallet as PezkuwichainPallet,
},
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
@@ -54,8 +54,7 @@ mod imports {
},
asset_hub_zagros_emulated_chain::{
genesis::{AssetHubZagrosAssetOwner, ED as ASSET_HUB_ZAGROS_ED},
AssetHubZagrosParaPezpallet,
AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
AssetHubZagrosParaPezpallet, AssetHubZagrosParaPezpallet as AssetHubZagrosPallet,
},
pez_penpal_emulated_chain::{
self,
@@ -64,24 +63,17 @@ mod imports {
LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub,
UniversalLocation as PenpalUniversalLocation,
},
PenpalAParaPezpallet,
PenpalAParaPezpallet as PenpalAPallet,
PenpalAssetOwner,
PenpalBParaPezpallet,
PenpalBParaPezpallet as PenpalBPallet,
PenpalAParaPezpallet, PenpalAParaPezpallet as PenpalAPallet, PenpalAssetOwner,
PenpalBParaPezpallet, PenpalBParaPezpallet as PenpalBPallet,
},
pezbridge_hub_zagros_emulated_chain::{
genesis::ED as BRIDGE_HUB_ZAGROS_ED, pezbridge_hub_zagros_runtime,
BridgeHubZagrosExistentialDeposit,
BridgeHubZagrosParaPezpallet,
BridgeHubZagrosParaPezpallet as BridgeHubZagrosPallet,
BridgeHubZagrosRuntimeOrigin,
BridgeHubZagrosExistentialDeposit, BridgeHubZagrosParaPezpallet,
BridgeHubZagrosParaPezpallet as BridgeHubZagrosPallet, BridgeHubZagrosRuntimeOrigin,
},
pezkuwichain_emulated_chain::PezkuwichainRelayPezpallet as PezkuwichainPallet,
zagros_emulated_chain::{
genesis::ED as ZAGROS_ED,
ZagrosRelayPezpallet,
ZagrosRelayPezpallet as ZagrosPallet,
genesis::ED as ZAGROS_ED, ZagrosRelayPezpallet, ZagrosRelayPezpallet as ZagrosPallet,
},
AssetHubPezkuwichainPara as AssetHubPezkuwichain,
AssetHubPezkuwichainParaReceiver as AssetHubPezkuwichainReceiver,
@@ -1,8 +1,5 @@
use crate as pezpallet_identity_kyc;
use pezframe_support::{
construct_runtime, derive_impl, parameter_types,
traits::ConstU128,
};
use pezframe_support::{construct_runtime, derive_impl, parameter_types, traits::ConstU128};
use pezframe_system::EnsureRoot;
use pezsp_core::H256;
use pezsp_runtime::BuildStorage;
@@ -141,9 +141,9 @@ fn finalize_epoch_calculates_rewards_correctly() {
assert_ok!(PezRewards::record_trust_score(RuntimeOrigin::signed(bob()))); // 50
assert_ok!(PezRewards::record_trust_score(RuntimeOrigin::signed(charlie()))); // 75
let total_trust: u128 = 100 + 50 + 75;
let expected_deadline = System::block_number() +
crate::BLOCKS_PER_EPOCH as u64 +
crate::CLAIM_PERIOD_BLOCKS as u64;
let expected_deadline = System::block_number()
+ crate::BLOCKS_PER_EPOCH as u64
+ crate::CLAIM_PERIOD_BLOCKS as u64;
let incentive_pot = PezRewards::incentive_pot_account_id();
let initial_pot_balance = pez_balance(&incentive_pot);
@@ -39,10 +39,10 @@ pub mod v1 {
let has_genesis_done =
if GenesisDistributionDone::<T>::get() { 1u64 } else { 0u64 };
let migrated = monthly_releases_count +
has_halving_info +
has_treasury_start +
has_genesis_done;
let migrated = monthly_releases_count
+ has_halving_info
+ has_treasury_start
+ has_genesis_done;
// Update storage version
STORAGE_VERSION.put::<Pezpallet<T>>();
@@ -220,8 +220,9 @@ pub mod pezpallet {
fallback_max_weight: None,
}]),
) {
Ok((hash, cost)) =>
Self::deposit_event(Event::PongSent(para, seq, payload, hash, cost)),
Ok((hash, cost)) => {
Self::deposit_event(Event::PongSent(para, seq, payload, hash, cost))
},
Err(e) => Self::deposit_event(Event::ErrorSendingPong(e, para, seq, payload)),
}
Ok(())
@@ -52,16 +52,8 @@ mod benchmarks {
let _ = T::Assets::mint_into(payment_asset, caller, payment_amount);
// Mint payment tokens to platform accounts for fee distribution
let _ = T::Assets::mint_into(
payment_asset,
&T::PlatformTreasury::get(),
payment_amount,
);
let _ = T::Assets::mint_into(
payment_asset,
&T::StakingRewardPool::get(),
payment_amount,
);
let _ = T::Assets::mint_into(payment_asset, &T::PlatformTreasury::get(), payment_amount);
let _ = T::Assets::mint_into(payment_asset, &T::StakingRewardPool::get(), payment_amount);
// Mint reward tokens to presale treasury for distribution
let reward_amount: T::Balance = 10_000_000_000u128.into();
@@ -289,8 +281,7 @@ mod benchmarks {
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
// Create presale (will get the presale_id we calculated)
let _ =
create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
// Make a contribution
let amount: u128 = 10_000u128;
@@ -325,13 +316,7 @@ mod benchmarks {
let (payment_asset, reward_asset) = setup_benchmark_assets::<T>(&caller, &presale_treasury);
// Create presale (will get the presale_id we calculated)
let _ = create_test_presale::<T>(
&caller,
payment_asset,
reward_asset,
false,
false,
);
let _ = create_test_presale::<T>(&caller, payment_asset, reward_asset, false, false);
// Add n contributors
for i in 0..n {
@@ -382,7 +367,7 @@ mod benchmarks {
limits: crate::ContributionLimits {
min_contribution: 100u128,
max_contribution: 10_000_000u128,
soft_cap: 1_000_000_000_000u128, // very high - will fail
soft_cap: 1_000_000_000_000u128, // very high - will fail
hard_cap: 2_000_000_000_000u128,
},
vesting: None,
@@ -60,7 +60,18 @@ pub mod pezpallet {
pub type PresaleId = u32;
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum PresaleStatus {
Pending, // Not started yet
@@ -72,7 +83,18 @@ pub mod pezpallet {
Finalized, // Tokens distributed (after Successful)
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub enum AccessControl {
@@ -80,7 +102,18 @@ pub mod pezpallet {
Whitelist, // Only whitelisted accounts
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct BonusTier {
@@ -90,7 +123,18 @@ pub mod pezpallet {
pub bonus_percentage: u8,
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct VestingSchedule<BlockNumber> {
@@ -102,7 +146,18 @@ pub mod pezpallet {
pub cliff_blocks: BlockNumber,
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct ContributionLimits {
@@ -116,7 +171,18 @@ pub mod pezpallet {
pub hard_cap: u128,
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct RefundConfig<BlockNumber> {
@@ -128,7 +194,18 @@ pub mod pezpallet {
pub grace_refund_fee_percent: u8,
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct PresaleCreationParams<BlockNumber> {
@@ -146,7 +223,18 @@ pub mod pezpallet {
pub refund_config: RefundConfig<BlockNumber>,
}
#[derive(Clone, Copy, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
#[derive(
Clone,
Copy,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
MaxEncodedLen,
TypeInfo,
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[codec(dumb_trait_bound)]
pub struct ContributionInfo<BlockNumber> {
@@ -162,7 +250,17 @@ pub mod pezpallet {
pub refund_fee_paid: u128,
}
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[derive(
Clone,
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
)]
#[scale_info(skip_type_params(T, MaxBonusTiers))]
#[codec(mel_bound(T: Config, MaxBonusTiers: Get<u32>))]
pub struct PresaleConfig<T: Config, MaxBonusTiers: Get<u32>> {
@@ -428,9 +526,15 @@ pub mod pezpallet {
ensure!(params.tokens_for_sale > 0, Error::<T>::InvalidTokensForSale);
ensure!(params.limits.soft_cap > 0, Error::<T>::InvalidTokensForSale);
ensure!(params.limits.soft_cap <= params.limits.hard_cap, Error::<T>::InvalidTokensForSale);
ensure!(
params.limits.soft_cap <= params.limits.hard_cap,
Error::<T>::InvalidTokensForSale
);
ensure!(params.refund_config.refund_fee_percent <= 100, Error::<T>::InvalidFeePercent);
ensure!(params.refund_config.grace_refund_fee_percent <= 100, Error::<T>::InvalidFeePercent);
ensure!(
params.refund_config.grace_refund_fee_percent <= 100,
Error::<T>::InvalidFeePercent
);
let presale_id = NextPresaleId::<T>::get();
let start_block = <pezframe_system::Pezpallet<T>>::block_number();
@@ -639,8 +743,8 @@ pub mod pezpallet {
// Handle vesting
if let Some(ref vesting) = presale.vesting {
let immediate = total_reward
.saturating_mul(vesting.immediate_release_percent as u128) /
100;
.saturating_mul(vesting.immediate_release_percent as u128)
/ 100;
if immediate > 0 {
let immediate_balance: T::Balance = immediate.into();
@@ -737,8 +841,7 @@ pub mod pezpallet {
let treasury = Self::presale_account_id(presale_id);
// Step 1: Transfer refund amount to user
let refund_amount_balance: T::Balance =
refund_amount.into();
let refund_amount_balance: T::Balance = refund_amount.into();
T::Assets::transfer(
presale.payment_asset,
&treasury,
@@ -819,10 +922,9 @@ pub mod pezpallet {
let vested_percent = elapsed_u128.saturating_mul(100) / duration_u128;
let immediate_percent = vesting.immediate_release_percent as u128;
let vesting_percent = 100u128.saturating_sub(immediate_percent);
let vested_amount = total_with_bonus
.saturating_mul(vesting_percent)
.saturating_mul(vested_percent) /
10000;
let vested_amount =
total_with_bonus.saturating_mul(vesting_percent).saturating_mul(vested_percent)
/ 10000;
let total_unlocked = vested_amount.saturating_add(already_claimed);
total_unlocked.saturating_sub(already_claimed)
};
@@ -831,8 +933,7 @@ pub mod pezpallet {
// Transfer tokens
let treasury = Self::presale_account_id(presale_id);
let claimable_balance: T::Balance =
claimable.into();
let claimable_balance: T::Balance = claimable.into();
T::Assets::transfer(
presale.reward_asset,
&treasury,
@@ -920,15 +1021,13 @@ pub mod pezpallet {
// Calculate non-refundable portion (burn + stakers = 50% of platform fee)
let platform_fee = contribution_info
.amount
.saturating_mul(T::PlatformFeePercent::get() as u128) /
100;
.saturating_mul(T::PlatformFeePercent::get() as u128)
/ 100;
let non_refundable = platform_fee.saturating_mul(50) / 100; // 1% (burn 25% + stakers 25%)
// Refund = 99% (contribution - non_refundable portion)
let refund_amount: T::Balance = contribution_info
.amount
.saturating_sub(non_refundable)
.into();
let refund_amount: T::Balance =
contribution_info.amount.saturating_sub(non_refundable).into();
T::Assets::transfer(
presale.payment_asset,
@@ -998,15 +1097,13 @@ pub mod pezpallet {
// Calculate non-refundable portion (burn + stakers = 50% of platform fee)
let platform_fee = contribution_info
.amount
.saturating_mul(T::PlatformFeePercent::get() as u128) /
100;
.saturating_mul(T::PlatformFeePercent::get() as u128)
/ 100;
let non_refundable = platform_fee.saturating_mul(50) / 100; // 1% (burn 25% + stakers 25%)
// Refund = 99% (contribution - non_refundable portion)
let refund_amount: T::Balance = contribution_info
.amount
.saturating_sub(non_refundable)
.into();
let refund_amount: T::Balance =
contribution_info.amount.saturating_sub(non_refundable).into();
T::Assets::transfer(
presale.payment_asset,
@@ -1082,12 +1179,9 @@ pub mod pezpallet {
let to_burn = total_fee.saturating_mul(25) / 100; // 25%
let to_stakers = total_fee.saturating_mul(25) / 100; // 25%
let to_treasury_balance: T::Balance =
to_treasury.into();
let to_burn_balance: T::Balance =
to_burn.into();
let to_stakers_balance: T::Balance =
to_stakers.into();
let to_treasury_balance: T::Balance = to_treasury.into();
let to_burn_balance: T::Balance = to_burn.into();
let to_stakers_balance: T::Balance = to_stakers.into();
// Note: Balance check removed - rely on Preservation::Expendable to handle insufficient
// balance gracefully The operations below will transfer/burn as much as possible
@@ -1,4 +1,7 @@
use crate::{mock::*, Error, Event, PresaleStatus, ContributionLimits, VestingSchedule, RefundConfig, PresaleCreationParams};
use crate::{
mock::*, ContributionLimits, Error, Event, PresaleCreationParams, PresaleStatus, RefundConfig,
VestingSchedule,
};
use pezframe_support::{assert_noop, assert_ok};
/// Helper function to create presale params with common defaults
@@ -33,12 +36,7 @@ fn make_presale_params(
tokens_for_sale,
duration,
is_whitelist,
limits: ContributionLimits {
min_contribution,
max_contribution,
soft_cap,
hard_cap,
},
limits: ContributionLimits { min_contribution, max_contribution, soft_cap, hard_cap },
vesting,
refund_config: RefundConfig {
grace_period_blocks,
@@ -108,12 +106,48 @@ fn create_multiple_presales_works() {
// Alice creates first presale
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Bob creates second presale
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(2),
2, 1, make_presale_params(20_000_000_000_000_000_000, 200, false, 20_000_000, 2_000_000_000, 10_000_000_000, 20_000_000_000, false, 0, 0, 0, 48, 10, 5)));
2,
1,
make_presale_params(
20_000_000_000_000_000_000,
200,
false,
20_000_000,
2_000_000_000,
10_000_000_000,
20_000_000_000,
false,
0,
0,
0,
48,
10,
5
)
));
// Check both presales exist
assert!(Presale::presales(0).is_some());
@@ -137,7 +171,25 @@ fn contribute_works() {
mint_assets(1, 1, 100_000_000_000_000_000_000);
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Mint wUSDT to Bob
mint_assets(2, 2, 1_000_000_000); // 1000 USDT
@@ -204,7 +256,25 @@ fn contribute_multiple_times_works() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// First contribution
assert_ok!(Presale::contribute(RuntimeOrigin::signed(2), 0, 50_000_000));
@@ -234,14 +304,50 @@ fn contribute_to_different_presales_works() {
// Create two presales
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Fund presale 0 treasury with reward tokens
mint_assets(1, presale_treasury(0), 10_000_000_000_000_000_000);
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(15_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
15_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Fund presale 1 treasury with reward tokens
mint_assets(1, presale_treasury(1), 15_000_000_000_000_000_000);
@@ -279,7 +385,25 @@ fn contribute_below_min_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Try to contribute less than minimum (10 USDT)
assert_noop!(
@@ -298,7 +422,25 @@ fn contribute_above_max_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Try to contribute more than maximum (1000 USDT)
assert_noop!(
@@ -369,7 +511,25 @@ fn contribute_after_presale_ended_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Move past presale end (block 1 + 100 = 101)
System::set_block_number(102);
@@ -390,7 +550,25 @@ fn finalize_presale_works() {
mint_assets(1, 1, 100_000_000_000_000_000_000); // 100,000 PEZ
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Mint PEZ to presale treasury for distribution
let treasury = presale_treasury(0);
@@ -428,8 +606,8 @@ fn finalize_presale_works() {
let contributor_pez = Assets::balance(1, i);
// Allow for small rounding differences (within 0.1%)
assert!(
contributor_pez >= expected_pez - 10_000_000_000_000_000 &&
contributor_pez <= expected_pez + 10_000_000_000_000_000,
contributor_pez >= expected_pez - 10_000_000_000_000_000
&& contributor_pez <= expected_pez + 10_000_000_000_000_000,
"Contributor {i} PEZ: {contributor_pez} (expected ~{expected_pez})"
);
}
@@ -449,7 +627,25 @@ fn finalize_presale_before_end_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Try to finalize immediately (use root to test the actual business logic error)
assert_noop!(
@@ -467,7 +663,25 @@ fn finalize_presale_non_root_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
System::set_block_number(101);
@@ -488,7 +702,25 @@ fn refund_works() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Bob contributes
let contribution = 100_000_000; // 100 USDT
@@ -596,7 +828,25 @@ fn refund_with_no_contribution_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Bob tries to refund without contributing
assert_noop!(Presale::refund(RuntimeOrigin::signed(2), 0), Error::<Test>::NoContribution);
@@ -612,7 +862,25 @@ fn cancel_presale_works() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Bob contributes
assert_ok!(Presale::contribute(RuntimeOrigin::signed(2), 0, 100_000_000));
@@ -637,7 +905,25 @@ fn cancel_presale_non_authorized_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Non-authorized user tries to cancel (needs EmergencyOrigin or Root)
assert_noop!(
@@ -655,7 +941,25 @@ fn emergency_cancel_by_root_works() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Root can cancel any presale (emergency)
assert_ok!(Presale::cancel_presale(RuntimeOrigin::root(), 0));
@@ -675,8 +979,25 @@ fn whitelist_presale_works() {
// Create whitelist presale
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, true, // whitelist enabled
10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
true, // whitelist enabled
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Bob tries to contribute (not whitelisted)
assert_noop!(
@@ -700,7 +1021,25 @@ fn add_to_whitelist_non_owner_fails() {
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, true, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
true,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Charlie tries to add Bob to Alice's presale whitelist
assert_noop!(
@@ -722,7 +1061,25 @@ fn finalize_presale_soft_cap_reached_success() {
mint_assets(1, 1, 100_000_000_000_000_000_000); // 100,000 PEZ
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Mint PEZ to presale treasury
let treasury = presale_treasury(0);
@@ -769,7 +1126,25 @@ fn finalize_presale_soft_cap_not_reached_fails() {
mint_assets(1, 1, 100_000_000_000_000_000_000);
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Contributors below soft cap (max is 1000 USDT each)
// Need to contribute less than soft cap of 5000 USDT
@@ -811,7 +1186,25 @@ fn batch_refund_failed_presale_works() {
mint_assets(1, 1, 100_000_000_000_000_000_000);
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Fund presale treasury with wUSDT for refunds
let treasury = presale_treasury(0);
@@ -864,7 +1257,25 @@ fn batch_refund_successful_presale_fails() {
mint_assets(1, 1, 100_000_000_000_000_000_000);
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
let treasury = presale_treasury(0);
mint_assets(1, treasury, 100_000_000_000_000_000_000);
@@ -906,7 +1317,25 @@ fn create_presale_with_soft_cap_greater_than_hard_cap_fails() {
assert_noop!(
Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000_000_000_000, 100, false, 10_000_000, 1_000_000_000, 15_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)),
2,
1,
make_presale_params(
10_000_000_000_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
15_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
),
Error::<Test>::InvalidTokensForSale
);
});
@@ -925,7 +1354,25 @@ fn debug_finalize_presale() {
// Create presale
assert_ok!(Presale::create_presale(
RuntimeOrigin::signed(1),
2, 1, make_presale_params(10_000_000_000, 100, false, 10_000_000, 1_000_000_000, 5_000_000_000, 10_000_000_000, false, 0, 0, 0, 24, 5, 2)));
2,
1,
make_presale_params(
10_000_000_000,
100,
false,
10_000_000,
1_000_000_000,
5_000_000_000,
10_000_000_000,
false,
0,
0,
0,
24,
5,
2
)
));
// Fund presale treasury with reward tokens
let treasury = presale_treasury(0);
@@ -266,8 +266,8 @@ pub mod pezpallet {
fn on_kyc_approved(who: &T::AccountId, referrer: &T::AccountId) {
// Security check: Verify on-chain that the user's KYC status is actually
// "Approved" before confirming the referral.
if pezpallet_identity_kyc::Pezpallet::<T>::get_kyc_status(who) ==
pezpallet_identity_kyc::types::KycLevel::Approved
if pezpallet_identity_kyc::Pezpallet::<T>::get_kyc_status(who)
== pezpallet_identity_kyc::types::KycLevel::Approved
{
// Check if this referral already exists (prevent double-counting)
if Referrals::<T>::contains_key(who) {
@@ -1,10 +1,7 @@
// pezkuwi/pallets/referral/src/mock.rs (Updated for new trustless model)
use crate as pezpallet_referral;
use pezframe_support::{
construct_runtime, derive_impl, parameter_types,
traits::ConstU128,
};
use pezframe_support::{construct_runtime, derive_impl, parameter_types, traits::ConstU128};
use pezframe_system::EnsureRoot;
use pezsp_core::H256;
use pezsp_runtime::BuildStorage;
@@ -1,6 +1,5 @@
use crate::{
mock::*, Error, Event, PendingReferrals, ReferralCount, Referrals,
ReferrerStatsStorage,
mock::*, Error, Event, PendingReferrals, ReferralCount, Referrals, ReferrerStatsStorage,
};
use pezframe_support::{assert_noop, assert_ok};
use pezpallet_identity_kyc::types::{OnCitizenshipRevoked, OnKycApproved};
@@ -261,13 +261,15 @@ impl ExtBuilder {
invulnerables: self
.stakers
.iter()
.filter_map(|(stash, _, _, status)| {
if let StakerStatus::Validator = status {
Some(*stash)
} else {
None
}
})
.filter_map(
|(stash, _, _, status)| {
if let StakerStatus::Validator = status {
Some(*stash)
} else {
None
}
},
)
.collect(),
force_era: pezpallet_staking::Forcing::ForceNew, // Yeni era başlatmaya zorla
min_nominator_bond: MinNominatorBond::get(), // Tanımlanan minimum değerleri kullan
@@ -49,7 +49,9 @@ mod benchmarks {
}
// Helper to ensure user has a citizen NFT
fn ensure_citizen_nft<T: Config + pezpallet_balances::Config>(who: T::AccountId) -> Result<(), DispatchError>
fn ensure_citizen_nft<T: Config + pezpallet_balances::Config>(
who: T::AccountId,
) -> Result<(), DispatchError>
where
T::CollectionId: Default + PartialOrd,
{
@@ -677,15 +677,16 @@ pub mod pezpallet {
Tiki::Welati => RoleAssignmentType::Automatic,
// Elected roles
Tiki::Parlementer | Tiki::SerokiMeclise | Tiki::Serok =>
RoleAssignmentType::Elected,
Tiki::Parlementer | Tiki::SerokiMeclise | Tiki::Serok => {
RoleAssignmentType::Elected
},
// Earned roles (automatically given by pezpallet-referral)
Tiki::Axa |
Tiki::Mamoste |
Tiki::Rewsenbîr |
Tiki::SerokêKomele |
Tiki::ModeratorêCivakê => RoleAssignmentType::Earned,
Tiki::Axa
| Tiki::Mamoste
| Tiki::Rewsenbîr
| Tiki::SerokêKomele
| Tiki::ModeratorêCivakê => RoleAssignmentType::Earned,
// Appointed roles (default)
_ => RoleAssignmentType::Appointed,
@@ -101,9 +101,7 @@ pub mod v1 {
let post_tiki_holder_count = TikiHolder::<T>::iter().count() as u32;
log::info!(" CitizenNft entries: {pre_citizen_count} -> {post_citizen_count}");
log::info!(
" UserTikis entries: {pre_user_tikis_count} -> {post_user_tikis_count}"
);
log::info!(" UserTikis entries: {pre_user_tikis_count} -> {post_user_tikis_count}");
log::info!(
" TikiHolder entries: {pre_tiki_holder_count} -> {post_tiki_holder_count}"
);
@@ -20,10 +20,13 @@ use pezsp_runtime::RuntimeAppPublic;
pub struct IdentityBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for IdentityBenchmarkHelper {
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature>
for IdentityBenchmarkHelper
{
fn sign_message(message: &[u8]) -> (UintAuthorityId, TestSignature) {
let signer = UintAuthorityId(0);
let signature = <UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
let signature =
<UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
(signer, signature)
}
}
@@ -33,7 +36,9 @@ impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for Ide
pub struct NftsBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature> for NftsBenchmarkHelper {
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature>
for NftsBenchmarkHelper
{
fn collection(i: u16) -> u32 {
i.into()
}
@@ -49,11 +49,7 @@ fn grant_appointed_role_works() {
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
// Tiki ver
assert_ok!(TikiPallet::grant_tiki(
RuntimeOrigin::root(),
user_account,
tiki_to_grant
));
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user_account, tiki_to_grant));
// Kullanıcının rollerini kontrol et
let user_tikis = TikiPallet::user_tikis(user_account);
@@ -189,11 +185,7 @@ fn grant_earned_role_works() {
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
// Earned rolü ver
assert_ok!(TikiPallet::grant_earned_role(
RuntimeOrigin::root(),
user_account,
earned_role
));
assert_ok!(TikiPallet::grant_earned_role(RuntimeOrigin::root(), user_account, earned_role));
// Rolün eklendiğini kontrol et
assert!(TikiPallet::user_tikis(user_account).contains(&earned_role));
@@ -237,11 +229,7 @@ fn unique_roles_work_correctly() {
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user2));
// İlk kullanıcıya unique rolü ver (elected role olarak)
assert_ok!(TikiPallet::grant_elected_role(
RuntimeOrigin::root(),
user1,
unique_role
));
assert_ok!(TikiPallet::grant_elected_role(RuntimeOrigin::root(), user1, unique_role));
// İkinci kullanıcıya aynı rolü vermeye çalış
assert_noop!(
@@ -279,21 +267,13 @@ fn revoke_tiki_works() {
// NFT bas ve role ver
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user_account));
assert_ok!(TikiPallet::grant_tiki(
RuntimeOrigin::root(),
user_account,
tiki_to_revoke
));
assert_ok!(TikiPallet::grant_tiki(RuntimeOrigin::root(), user_account, tiki_to_revoke));
// Rolün eklendiğini kontrol et
assert!(TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
// Rolü kaldır
assert_ok!(TikiPallet::revoke_tiki(
RuntimeOrigin::root(),
user_account,
tiki_to_revoke
));
assert_ok!(TikiPallet::revoke_tiki(RuntimeOrigin::root(), user_account, tiki_to_revoke));
// Rolün kaldırıldığını kontrol et
assert!(!TikiPallet::user_tikis(user_account).contains(&tiki_to_revoke));
@@ -332,11 +312,7 @@ fn revoke_unique_role_clears_holder() {
// NFT bas ve unique rolü ver
assert_ok!(TikiPallet::force_mint_citizen_nft(RuntimeOrigin::root(), user));
assert_ok!(TikiPallet::grant_elected_role(
RuntimeOrigin::root(),
user,
unique_role
));
assert_ok!(TikiPallet::grant_elected_role(RuntimeOrigin::root(), user, unique_role));
// TikiHolder'da kayıtlı olduğunu kontrol et
assert_eq!(TikiPallet::tiki_holder(unique_role), Some(user));
@@ -152,7 +152,9 @@ pub mod pezpallet {
pub struct Pezpallet<T>(_);
#[pezpallet::config]
pub trait Config: pezframe_system::Config<RuntimeEvent: From<Event<Self>>> + pezpallet_identity_kyc::Config {
pub trait Config:
pezframe_system::Config<RuntimeEvent: From<Event<Self>>> + pezpallet_identity_kyc::Config
{
type WeightInfo: WeightInfo;
type Score: Member
@@ -303,8 +303,8 @@ fn update_all_trust_scores_emits_event() {
let events = System::events();
let bulk_update_event = events.iter().any(|event| {
matches!(event.event, RuntimeEvent::TrustPallet(Event::BulkTrustScoreUpdate { .. })) ||
matches!(
matches!(event.event, RuntimeEvent::TrustPallet(Event::BulkTrustScoreUpdate { .. }))
|| matches!(
event.event,
RuntimeEvent::TrustPallet(Event::AllTrustScoresUpdated { .. })
)
@@ -412,7 +412,6 @@ fn multiple_users_independent_scores() {
#[test]
fn trust_score_provider_trait_returns_zero_initially() {
new_test_ext().execute_with(|| {
let account = 1u64;
let score = TrustPallet::trust_score_of(account);
assert_eq!(score, 0);
@@ -422,7 +421,6 @@ fn trust_score_provider_trait_returns_zero_initially() {
#[test]
fn trust_score_provider_trait_returns_updated_score() {
new_test_ext().execute_with(|| {
let account = 1u64;
TrustPallet::update_score_for_account(&account).unwrap();
@@ -434,7 +432,6 @@ fn trust_score_provider_trait_returns_updated_score() {
#[test]
fn trust_score_provider_trait_multiple_users() {
new_test_ext().execute_with(|| {
TrustPallet::update_score_for_account(&1u64).unwrap();
TrustPallet::update_score_for_account(&2u64).unwrap();
@@ -928,9 +928,7 @@ pub mod pezpallet {
// Create appointment process
let documents: BoundedVec<BoundedVec<u8, ConstU32<1000>>, ConstU32<10>> =
vec![justification]
.try_into()
.map_err(|_| Error::<T>::CalculationOverflow)?;
vec![justification].try_into().map_err(|_| Error::<T>::CalculationOverflow)?;
let appointment_process = AppointmentProcess {
process_id,
@@ -1099,9 +1097,9 @@ pub mod pezpallet {
// For Parliament decisions, voter must be a parliament member
match proposal.decision_type {
CollectiveDecisionType::ParliamentSimpleMajority |
CollectiveDecisionType::ParliamentSuperMajority |
CollectiveDecisionType::ParliamentAbsoluteMajority => {
CollectiveDecisionType::ParliamentSimpleMajority
| CollectiveDecisionType::ParliamentSuperMajority
| CollectiveDecisionType::ParliamentAbsoluteMajority => {
// Check if voter is in parliament
let members = ParliamentMembers::<T>::get();
let is_member = members.iter().any(|m| m.account == voter);
@@ -1127,12 +1125,15 @@ pub mod pezpallet {
ActiveProposals::<T>::mutate(proposal_id, |proposal_opt| {
if let Some(proposal) = proposal_opt {
match vote {
VoteChoice::Aye =>
proposal.aye_votes = proposal.aye_votes.saturating_add(1),
VoteChoice::Nay =>
proposal.nay_votes = proposal.nay_votes.saturating_add(1),
VoteChoice::Abstain =>
proposal.abstain_votes = proposal.abstain_votes.saturating_add(1),
VoteChoice::Aye => {
proposal.aye_votes = proposal.aye_votes.saturating_add(1)
},
VoteChoice::Nay => {
proposal.nay_votes = proposal.nay_votes.saturating_add(1)
},
VoteChoice::Abstain => {
proposal.abstain_votes = proposal.abstain_votes.saturating_add(1)
},
}
proposal.votes_cast = proposal.votes_cast.saturating_add(1);
}
@@ -1350,14 +1351,15 @@ pub mod pezpallet {
winners: &[T::AccountId],
) -> Result<(), Error<T>> {
match election_type {
ElectionType::Presidential =>
ElectionType::Presidential => {
if let Some(winner) = winners.first() {
CurrentOfficials::<T>::insert(GovernmentPosition::Serok, winner);
},
}
},
ElectionType::Parliamentary => {
let current_block = pezframe_system::Pezpallet::<T>::block_number();
let term_end = current_block +
BlockNumberFor::<T>::from(4u32 * 365u32 * 24u32 * 60u32 * 10u32);
let term_end = current_block
+ BlockNumberFor::<T>::from(4u32 * 365u32 * 24u32 * 60u32 * 10u32);
let parliament_members: Result<BoundedVec<_, _>, _> = winners
.iter()
@@ -1382,10 +1384,11 @@ pub mod pezpallet {
term_start: current_block,
});
},
ElectionType::SpeakerElection =>
ElectionType::SpeakerElection => {
if let Some(winner) = winners.first() {
CurrentOfficials::<T>::insert(GovernmentPosition::MeclisBaskanı, winner);
},
}
},
_ => {},
}
Ok(())
@@ -1397,15 +1400,16 @@ pub mod pezpallet {
decision_type: &CollectiveDecisionType,
) -> Result<bool, Error<T>> {
match decision_type {
CollectiveDecisionType::ExecutiveDecision =>
Ok(CurrentOfficials::<T>::get(GovernmentPosition::Serok) ==
Some(proposer.clone())),
CollectiveDecisionType::ExecutiveDecision => {
Ok(CurrentOfficials::<T>::get(GovernmentPosition::Serok)
== Some(proposer.clone()))
},
_ => {
let is_parliamentarian = ParliamentMembers::<T>::get()
.iter()
.any(|member| member.account == *proposer);
let is_president = CurrentOfficials::<T>::get(GovernmentPosition::Serok) ==
Some(proposer.clone());
let is_president = CurrentOfficials::<T>::get(GovernmentPosition::Serok)
== Some(proposer.clone());
Ok(is_parliamentarian || is_president)
},
@@ -1415,12 +1419,15 @@ pub mod pezpallet {
/// Calculate voting threshold
fn get_voting_threshold(decision_type: &CollectiveDecisionType) -> u32 {
match decision_type {
CollectiveDecisionType::ParliamentSimpleMajority =>
(T::ParliamentSize::get() / 2) + 1,
CollectiveDecisionType::ParliamentSuperMajority =>
(T::ParliamentSize::get() * 2) / 3,
CollectiveDecisionType::ParliamentAbsoluteMajority =>
(T::ParliamentSize::get() * 3) / 4,
CollectiveDecisionType::ParliamentSimpleMajority => {
(T::ParliamentSize::get() / 2) + 1
},
CollectiveDecisionType::ParliamentSuperMajority => {
(T::ParliamentSize::get() * 2) / 3
},
CollectiveDecisionType::ParliamentAbsoluteMajority => {
(T::ParliamentSize::get() * 3) / 4
},
CollectiveDecisionType::ConstitutionalReview => (T::DiwanSize::get() * 2) / 3,
CollectiveDecisionType::ConstitutionalUnanimous => T::DiwanSize::get(),
_ => T::ParliamentSize::get() / 2 + 1,
@@ -1553,10 +1560,10 @@ impl<T: Config> Pezpallet<T> {
/// Check if an account is any type of governance member
/// Used for fee exemption in governance-related transactions
pub fn is_governance_member(who: &T::AccountId) -> bool {
Self::is_serok(who) ||
Self::is_parliament_member(who) ||
Self::is_diwan_member(who) ||
Self::is_minister(who)
Self::is_serok(who)
|| Self::is_parliament_member(who)
|| Self::is_diwan_member(who)
|| Self::is_minister(who)
}
/// Check if account is Serok (President)
@@ -41,7 +41,8 @@ pub mod v1 {
let elections_count = ActiveElections::<T>::iter().count() as u64;
let proposals_count = ActiveProposals::<T>::iter().count() as u64;
let migrated = officials_count + ministers_count + elections_count + proposals_count;
let migrated =
officials_count + ministers_count + elections_count + proposals_count;
// Update storage version
STORAGE_VERSION.put::<Pezpallet<T>>();
@@ -143,9 +144,8 @@ pub mod v1 {
pre_appointments_count,
pre_proposals_count,
pre_collective_votes_count,
): PreUpgradeState =
Decode::decode(&mut &state[..])
.map_err(|_| "Failed to decode pre-upgrade state")?;
): PreUpgradeState = Decode::decode(&mut &state[..])
.map_err(|_| "Failed to decode pre-upgrade state")?;
log::info!("🔍 Post-upgrade check for pezpallet-welati");
@@ -170,19 +170,33 @@ pub mod v1 {
let post_proposals_count = ActiveProposals::<T>::iter().count() as u32;
let post_collective_votes_count = CollectiveVotes::<T>::iter().count() as u32;
log::info!(" CurrentOfficials entries: {pre_officials_count} -> {post_officials_count}");
log::info!(" CurrentMinisters entries: {pre_ministers_count} -> {post_ministers_count}");
log::info!(" ParliamentMembers entries: {pre_parliament_count} -> {post_parliament_count}");
log::info!(
" CurrentOfficials entries: {pre_officials_count} -> {post_officials_count}"
);
log::info!(
" CurrentMinisters entries: {pre_ministers_count} -> {post_ministers_count}"
);
log::info!(
" ParliamentMembers entries: {pre_parliament_count} -> {post_parliament_count}"
);
log::info!(" DiwanMembers entries: {pre_diwan_count} -> {post_diwan_count}");
log::info!(" AppointedOfficials entries: {pre_appointed_count} -> {post_appointed_count}");
log::info!(" ActiveElections entries: {pre_elections_count} -> {post_elections_count}");
log::info!(" ElectionCandidates entries: {pre_candidates_count} -> {post_candidates_count}");
log::info!(
" AppointedOfficials entries: {pre_appointed_count} -> {post_appointed_count}"
);
log::info!(
" ActiveElections entries: {pre_elections_count} -> {post_elections_count}"
);
log::info!(
" ElectionCandidates entries: {pre_candidates_count} -> {post_candidates_count}"
);
log::info!(" ElectionVotes entries: {pre_votes_count} -> {post_votes_count}");
log::info!(" ElectionResults entries: {pre_results_count} -> {post_results_count}");
log::info!(" ElectoralDistrictConfig entries: {pre_districts_count} -> {post_districts_count}");
log::info!(" PendingNominations entries: {pre_nominations_count} -> {post_nominations_count}");
log::info!(" AppointmentProcesses entries: {pre_appointments_count} -> {post_appointments_count}");
log::info!(" ActiveProposals entries: {pre_proposals_count} -> {post_proposals_count}");
log::info!(
" ActiveProposals entries: {pre_proposals_count} -> {post_proposals_count}"
);
log::info!(" CollectiveVotes entries: {pre_collective_votes_count} -> {post_collective_votes_count}");
// Verify no data was lost
@@ -125,7 +125,9 @@ parameter_types! {
pub struct NftsBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature> for NftsBenchmarkHelper {
impl pezpallet_nfts::BenchmarkHelper<u32, u32, UintAuthorityId, AccountId, TestSignature>
for NftsBenchmarkHelper
{
fn collection(i: u16) -> u32 {
i.into()
}
@@ -192,10 +194,13 @@ parameter_types! {
pub struct IdentityBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature> for IdentityBenchmarkHelper {
impl pezpallet_identity::BenchmarkHelper<UintAuthorityId, TestSignature>
for IdentityBenchmarkHelper
{
fn sign_message(message: &[u8]) -> (UintAuthorityId, TestSignature) {
let signer = UintAuthorityId(0);
let signature = <UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
let signature =
<UintAuthorityId as RuntimeAppPublic>::sign(&signer, &message.to_vec()).unwrap();
(signer, signature)
}
}
@@ -1339,31 +1339,33 @@ impl OfficialRoleInfo for OfficialRole {
fn nominating_minister(&self) -> MinisterRole {
match self {
OfficialRole::Dadger |
OfficialRole::Dozger |
OfficialRole::Hiquqnas |
OfficialRole::Noter => MinisterRole::AdvaletWeziri,
OfficialRole::Dadger
| OfficialRole::Dozger
| OfficialRole::Hiquqnas
| OfficialRole::Noter => MinisterRole::AdvaletWeziri,
OfficialRole::Xezinedar | OfficialRole::Bacgir | OfficialRole::GerinendeyeCavkaniye =>
MinisterRole::XezineWeziri,
OfficialRole::Xezinedar | OfficialRole::Bacgir | OfficialRole::GerinendeyeCavkaniye => {
MinisterRole::XezineWeziri
},
OfficialRole::OperatoreTore |
OfficialRole::PisporeEwlehiyaSiber |
OfficialRole::GerinendeyeDaneye => MinisterRole::TeknolojîWeziri,
OfficialRole::OperatoreTore
| OfficialRole::PisporeEwlehiyaSiber
| OfficialRole::GerinendeyeDaneye => MinisterRole::TeknolojîWeziri,
OfficialRole::Berdevk | OfficialRole::Qeydkar => MinisterRole::NavxweWeziri,
OfficialRole::Balyoz | OfficialRole::Navbeynkar | OfficialRole::ParezvaneCandi =>
MinisterRole::DerveWeziri,
OfficialRole::Balyoz | OfficialRole::Navbeynkar | OfficialRole::ParezvaneCandi => {
MinisterRole::DerveWeziri
},
OfficialRole::Mufetis | OfficialRole::KaliteKontrolker => MinisterRole::DenetimWeziri,
OfficialRole::Bazargan | OfficialRole::RêvebereProjeyê => MinisterRole::AbûrîWeziri,
OfficialRole::Feqi |
OfficialRole::Perwerdekar |
OfficialRole::Rewsenbir |
OfficialRole::Mamoste => MinisterRole::PerwerdeDiyanetWeziri,
OfficialRole::Feqi
| OfficialRole::Perwerdekar
| OfficialRole::Rewsenbir
| OfficialRole::Mamoste => MinisterRole::PerwerdeDiyanetWeziri,
// Mela özel durum - doğrudan Serok atar
OfficialRole::Mela => MinisterRole::AdvaletWeziri, // Placeholder
@@ -1373,11 +1375,11 @@ impl OfficialRoleInfo for OfficialRole {
fn requires_parliament_approval(&self) -> bool {
match self {
// Yüksek düzey pozisyonlar Parlamento onayı gerektirir
OfficialRole::Dadger |
OfficialRole::Xezinedar |
OfficialRole::PisporeEwlehiyaSiber |
OfficialRole::Mufetis |
OfficialRole::Balyoz => true,
OfficialRole::Dadger
| OfficialRole::Xezinedar
| OfficialRole::PisporeEwlehiyaSiber
| OfficialRole::Mufetis
| OfficialRole::Balyoz => true,
// Diğerleri sadece Serok onayı
_ => false,
}
@@ -101,7 +101,10 @@ fn asset_hub_pezkuwichain_genesis(
) -> serde_json::Value {
// Verify total PEZ minted at genesis equals PEZ_TOTAL_SUPPLY (5 billion)
debug_assert_eq!(
PEZ_TREASURY_ALLOCATION + PEZ_REWARDS_POOL + PEZ_FOUNDER_ALLOCATION + PEZ_PRESALE_ALLOCATION,
PEZ_TREASURY_ALLOCATION
+ PEZ_REWARDS_POOL
+ PEZ_FOUNDER_ALLOCATION
+ PEZ_PRESALE_ALLOCATION,
PEZ_TOTAL_SUPPLY,
"PEZ genesis allocations must equal total supply"
);
@@ -609,99 +609,99 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances { .. } |
RuntimeCall::Assets { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
RuntimeCall::Balances { .. }
| RuntimeCall::Assets { .. }
| RuntimeCall::NftFractionalization { .. }
| RuntimeCall::Nfts { .. }
| RuntimeCall::Uniques { .. }
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Assets => {
matches!(
c,
RuntimeCall::Assets { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
RuntimeCall::Assets { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
| RuntimeCall::NftFractionalization { .. }
| RuntimeCall::Nfts { .. }
| RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::create { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::destroy { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::redeposit { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::transfer_ownership { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_team { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_max_supply { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_collection { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::create { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::destroy { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::transfer_ownership { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_team { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_attribute { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_attribute { .. }) |
RuntimeCall::Uniques(
RuntimeCall::Assets(TrustBackedAssetsCall::create { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::create { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::destroy { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::redeposit { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::transfer_ownership { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_team { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_max_supply { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_collection { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::create { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::destroy { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::transfer_ownership { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_team { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_attribute { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::clear_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::clear_attribute { .. })
| RuntimeCall::Uniques(
pezpallet_uniques::Call::clear_collection_metadata { .. }
) | RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
) | RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::AssetManager => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::force_mint { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::update_mint_settings { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::mint_pre_signed { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_attributes_pre_signed { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_transfer { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::unlock_item_transfer { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_properties { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::clear_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::clear_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::mint { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::burn { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::freeze { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::thaw { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::freeze_collection { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::thaw_collection { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::block { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::force_mint { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::update_mint_settings { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::mint_pre_signed { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_attributes_pre_signed { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_transfer { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::unlock_item_transfer { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_properties { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::clear_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::clear_collection_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::mint { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::burn { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::freeze { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::thaw { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::freeze_collection { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::thaw_collection { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -44,12 +44,14 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1))),
AllOfCounted { count, .. } =>
weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1))),
AllOfCounted { count, .. } => {
weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1)))
},
},
}
}
@@ -722,10 +722,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::OldSudoBalances |
ProxyType::OldIdentityJudgement |
ProxyType::OldAuction |
ProxyType::OldParaRegistration => false,
ProxyType::OldSudoBalances
| ProxyType::OldIdentityJudgement
| ProxyType::OldAuction
| ProxyType::OldParaRegistration => false,
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances { .. } |
@@ -744,109 +744,109 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Assets => {
matches!(
c,
RuntimeCall::Assets { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
RuntimeCall::Assets { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
| RuntimeCall::NftFractionalization { .. }
| RuntimeCall::Nfts { .. }
| RuntimeCall::Uniques { .. }
)
},
ProxyType::AssetOwner => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::create { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::create { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::destroy { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::redeposit { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::transfer_ownership { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_team { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_max_supply { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_collection { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::create { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::destroy { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::transfer_ownership { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_team { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_attribute { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_attribute { .. }) |
RuntimeCall::Uniques(
RuntimeCall::Assets(TrustBackedAssetsCall::create { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::start_destroy { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::destroy_accounts { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::destroy_approvals { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::finish_destroy { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::transfer_ownership { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::set_min_balance { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::create { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::destroy { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::redeposit { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::transfer_ownership { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_team { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_max_supply { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_collection { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::create { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::destroy { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::transfer_ownership { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_team { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_attribute { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::clear_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::clear_attribute { .. })
| RuntimeCall::Uniques(
pezpallet_uniques::Call::clear_collection_metadata { .. }
) | RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
) | RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::AssetManager => matches!(
c,
RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::block { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. }) |
RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::force_mint { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::update_mint_settings { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::mint_pre_signed { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_attributes_pre_signed { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_transfer { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::unlock_item_transfer { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_properties { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::clear_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_metadata { .. }) |
RuntimeCall::Nfts(pezpallet_nfts::Call::clear_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::mint { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::burn { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::freeze { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::thaw { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::freeze_collection { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::thaw_collection { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Assets(TrustBackedAssetsCall::mint { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::burn { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::freeze { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::block { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::touch_other { .. })
| RuntimeCall::Assets(TrustBackedAssetsCall::refund_other { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::force_mint { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::update_mint_settings { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::mint_pre_signed { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_attributes_pre_signed { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_transfer { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::unlock_item_transfer { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::lock_item_properties { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::clear_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::set_collection_metadata { .. })
| RuntimeCall::Nfts(pezpallet_nfts::Call::clear_collection_metadata { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::mint { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::burn { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::freeze { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::thaw { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::freeze_collection { .. })
| RuntimeCall::Uniques(pezpallet_uniques::Call::thaw_collection { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
// New variants introduced by the Asset Hub Migration from the Relay Chain.
ProxyType::Governance => matches!(
c,
RuntimeCall::Treasury(..) |
RuntimeCall::Utility(..) |
RuntimeCall::ConvictionVoting(..) |
RuntimeCall::Referenda(..) |
RuntimeCall::Whitelist(..)
RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
| RuntimeCall::ConvictionVoting(..)
| RuntimeCall::Referenda(..)
| RuntimeCall::Whitelist(..)
),
ProxyType::Staking => {
matches!(
c,
RuntimeCall::Staking(..) |
RuntimeCall::Session(..) |
RuntimeCall::Utility(..) |
RuntimeCall::NominationPools(..) |
RuntimeCall::VoterList(..)
RuntimeCall::Staking(..)
| RuntimeCall::Session(..)
| RuntimeCall::Utility(..)
| RuntimeCall::NominationPools(..)
| RuntimeCall::VoterList(..)
)
},
ProxyType::NominationPools => {
@@ -864,10 +864,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
(ProxyType::Assets, ProxyType::AssetManager) => true,
(
ProxyType::NonTransfer,
ProxyType::Collator |
ProxyType::Governance |
ProxyType::Staking |
ProxyType::NominationPools,
ProxyType::Collator
| ProxyType::Governance
| ProxyType::Staking
| ProxyType::NominationPools,
) => true,
_ => false,
}
@@ -47,12 +47,14 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1))),
AllOfCounted { count, .. } =>
weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1))),
AllOfCounted { count, .. } => {
weight.saturating_mul(MAX_ASSETS.min((*count as u64).max(1)))
},
},
}
}
@@ -284,9 +284,9 @@ impl Contains<Location> for FellowshipEntities {
fn contains(location: &Location) -> bool {
matches!(
location.unpack(),
(1, [Teyrchain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }]) |
(1, [Teyrchain(COLLECTIVES_ID), PalletInstance(64)]) |
(1, [Teyrchain(COLLECTIVES_ID), PalletInstance(65)])
(1, [Teyrchain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }])
| (1, [Teyrchain(COLLECTIVES_ID), PalletInstance(64)])
| (1, [Teyrchain(COLLECTIVES_ID), PalletInstance(65)])
)
}
}
@@ -113,8 +113,9 @@ pub mod foreign_assets_reserves {
// At first, start migrating assets.
None => Self::asset_step(None),
// Migrate any remaining assets.
Some(MigrationState::Asset(maybe_last_asset)) =>
Self::asset_step(Some(maybe_last_asset)),
Some(MigrationState::Asset(maybe_last_asset)) => {
Self::asset_step(Some(maybe_last_asset))
},
// After the last asset, migration is finished.
Some(MigrationState::Finished) => {
tracing::info!(target: "runtime::ForeignAssetsReservesMigration", "migration finished");
@@ -73,8 +73,9 @@ pub(crate) fn assert_matches_reserve_asset_deposited_instructions<RuntimeCall: D
})
.expect("expected instruction BuyExecution")
.match_next_inst(|instr| match instr {
DepositAsset { assets: _, beneficiary } if beneficiary == expected_beneficiary =>
Ok(()),
DepositAsset { assets: _, beneficiary } if beneficiary == expected_beneficiary => {
Ok(())
},
_ => Err(ProcessMessageError::BadFormat),
})
.expect("expected instruction DepositAsset");
@@ -615,9 +615,9 @@ pub fn teleports_for_foreign_assets_works<
);
let asset_to_teleport_away = asset_minimum_asset_balance * 3;
assert!(
asset_to_teleport_away <
(target_account_balance_before_teleport -
asset_minimum_asset_balance.into())
asset_to_teleport_away
< (target_account_balance_before_teleport
- asset_minimum_asset_balance.into())
.into()
);
@@ -1190,12 +1190,12 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_teyrchain_assets_wor
.with_session_keys(collator_session_keys.session_keys())
.with_balances(vec![(
foreign_creator_as_account_id.clone(),
existential_deposit +
asset_deposit +
metadata_deposit_base +
metadata_deposit_per_byte_eta +
buy_execution_fee_amount.into() +
buy_execution_fee_amount.into(),
existential_deposit
+ asset_deposit
+ metadata_deposit_base
+ metadata_deposit_per_byte_eta
+ buy_execution_fee_amount.into()
+ buy_execution_fee_amount.into(),
)])
.with_tracing()
.build()
@@ -1209,11 +1209,11 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_teyrchain_assets_wor
<pezpallet_balances::Pezpallet<Runtime>>::free_balance(
&foreign_creator_as_account_id
),
existential_deposit +
asset_deposit + metadata_deposit_base +
metadata_deposit_per_byte_eta +
buy_execution_fee_amount.into() +
buy_execution_fee_amount.into()
existential_deposit
+ asset_deposit + metadata_deposit_base
+ metadata_deposit_per_byte_eta
+ buy_execution_fee_amount.into()
+ buy_execution_fee_amount.into()
);
additional_checks_before();
@@ -1549,9 +1549,9 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
// then verify the arithmetics check out on final balance.
let delivery_fees_buffer = 40_000_000_000u128;
// drip 2xED + transfer_amount + delivery_fees_buffer to Alice account
let alice_account_init_balance = existential_deposit.saturating_mul(2.into()) +
balance_to_transfer.into() +
delivery_fees_buffer.into();
let alice_account_init_balance = existential_deposit.saturating_mul(2.into())
+ balance_to_transfer.into()
+ delivery_fees_buffer.into();
let _ = <pezpallet_balances::Pezpallet<Runtime>>::deposit_creating(
&alice_account,
alice_account_init_balance,
@@ -1565,9 +1565,9 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
// we just check here, that user retains enough balance after withdrawal
// and also we check if `balance_to_transfer` is more than `existential_deposit`,
assert!(
(<pezpallet_balances::Pezpallet<Runtime>>::free_balance(&alice_account) -
balance_to_transfer.into()) >=
existential_deposit
(<pezpallet_balances::Pezpallet<Runtime>>::free_balance(&alice_account)
- balance_to_transfer.into())
>= existential_deposit
);
// SA has just ED
assert_eq!(
@@ -1609,8 +1609,9 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
.into_iter()
.filter_map(|e| unwrap_xcmp_queue_event(e.event.encode()))
.find_map(|e| match e {
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } =>
Some(message_hash),
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => {
Some(message_hash)
},
_ => None,
});
@@ -153,9 +153,9 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
// we just check here, that user retains enough balance after withdrawal
// and also we check if `balance_to_transfer` is more than `existential_deposit`,
assert!(
(<pezpallet_balances::Pezpallet<Runtime>>::free_balance(&alice_account) -
balance_to_transfer.into()) >=
existential_deposit
(<pezpallet_balances::Pezpallet<Runtime>>::free_balance(&alice_account)
- balance_to_transfer.into())
>= existential_deposit
);
// SA has just ED
assert_eq!(
@@ -220,8 +220,9 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
.into_iter()
.filter_map(|e| unwrap_xcmp_queue_event(e.event.encode()))
.find_map(|e| match e {
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } =>
Some(message_hash),
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => {
Some(message_hash)
},
_ => None,
});
@@ -268,7 +269,9 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
// explicit unpaid execution on BridgeHub)
UnpaidExecution { weight_limit, check_origin }
if weight_limit == &Unlimited && check_origin.is_none() =>
Ok(()),
{
Ok(())
},
_ => Err(ProcessMessageError::BadFormat),
})
.expect("contains UnpaidExecution")
@@ -322,8 +325,8 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
let delivery_fees_account_balance_after =
<pezpallet_balances::Pezpallet<Runtime>>::free_balance(&delivery_fees_account);
assert!(
delivery_fees_account_balance_after - delivery_fees.into() >=
delivery_fees_account_balance_before
delivery_fees_account_balance_after - delivery_fees.into()
>= delivery_fees_account_balance_before
);
}
})
@@ -44,8 +44,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -302,8 +302,9 @@ pub struct AllowFromEthereumFrontend;
impl Contains<Location> for AllowFromEthereumFrontend {
fn contains(location: &Location) -> bool {
match location.unpack() {
(1, [Teyrchain(para_id), PalletInstance(index)]) =>
return *para_id == ASSET_HUB_ID && *index == FRONTEND_PALLET_INDEX,
(1, [Teyrchain(para_id), PalletInstance(index)]) => {
return *para_id == ASSET_HUB_ID && *index == FRONTEND_PALLET_INDEX
},
_ => false,
}
}
@@ -45,8 +45,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -47,8 +47,9 @@ where
message.matcher().match_next_inst_while(
|_| true,
|inst| match inst {
ExportMessage { network, .. } if ToGlobalConsensus::contains(network) =>
Err(ProcessMessageError::Unsupported),
ExportMessage { network, .. } if ToGlobalConsensus::contains(network) => {
Err(ProcessMessageError::Unsupported)
},
_ => Ok(ControlFlow::Continue(())),
},
)?;
@@ -122,8 +122,9 @@ where
) -> Result<bool, ProcessMessageError> {
use AggregateMessageOrigin::*;
match origin {
Here | Parent | Sibling(_) =>
XcmpProcessor::process_message(message, origin, meter, id),
Here | Parent | Sibling(_) => {
XcmpProcessor::process_message(message, origin, meter, id)
},
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
SnowbridgeV2(_) => Err(ProcessMessageError::Unsupported),
}
@@ -155,8 +156,9 @@ where
) -> Result<bool, ProcessMessageError> {
use AggregateMessageOrigin::*;
match origin {
Here | Parent | Sibling(_) =>
XcmpProcessor::process_message(message, origin, meter, id),
Here | Parent | Sibling(_) => {
XcmpProcessor::process_message(message, origin, meter, id)
},
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
SnowbridgeV2(_) => SnowbridgeProcessorV2::process_message(message, origin, meter, id),
}
@@ -303,8 +303,8 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
// value here is tricky - there are several transaction payment pallets and we don't
// want to introduce additional bounds and traits here just for that, so let's just
// select some presumably large value
core::cmp::max::<Runtime::Balance>(Runtime::ExistentialDeposit::get(), 1u32.into()) *
100_000_000u32.into(),
core::cmp::max::<Runtime::Balance>(Runtime::ExistentialDeposit::get(), 1u32.into())
* 100_000_000u32.into(),
)],
|| {
let mut alice = [0u8; 32];
@@ -445,8 +445,8 @@ pub(crate) mod for_pallet_xcm_bridge_hub {
let buy_execution_fee_amount = 5_000_000_000_000_u128;
let buy_execution_fee = (TokenLocation::get(), buy_execution_fee_amount).into();
let balance_needed = <Runtime as pezpallet_balances::Config>::ExistentialDeposit::get() +
buy_execution_fee_amount.into();
let balance_needed = <Runtime as pezpallet_balances::Config>::ExistentialDeposit::get()
+ buy_execution_fee_amount.into();
let source_account_id =
LocationToAccountId::convert_location(&source).expect("valid location");
let _ = <pezpallet_balances::Pezpallet<Runtime>>::mint_into(
@@ -563,8 +563,8 @@ pub(crate) mod for_pallet_xcm_bridge_hub {
let buy_execution_fee_amount = 2_500_000_000_000_u128;
let buy_execution_fee = (TokenLocation::get(), buy_execution_fee_amount).into();
let balance_needed = <Runtime as pezpallet_balances::Config>::ExistentialDeposit::get() +
buy_execution_fee_amount.into();
let balance_needed = <Runtime as pezpallet_balances::Config>::ExistentialDeposit::get()
+ buy_execution_fee_amount.into();
let source_account_id =
LocationToAccountId::convert_location(&expected_source).expect("valid location");
let _ = <pezpallet_balances::Pezpallet<Runtime>>::mint_into(
@@ -332,49 +332,49 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Alliance => matches!(
c,
RuntimeCall::AllianceMotion { .. } |
RuntimeCall::Alliance { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::AllianceMotion { .. }
| RuntimeCall::Alliance { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Fellowship => matches!(
c,
RuntimeCall::FellowshipCollective { .. } |
RuntimeCall::FellowshipReferenda { .. } |
RuntimeCall::FellowshipCore { .. } |
RuntimeCall::FellowshipSalary { .. } |
RuntimeCall::FellowshipTreasury { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::FellowshipCollective { .. }
| RuntimeCall::FellowshipReferenda { .. }
| RuntimeCall::FellowshipCore { .. }
| RuntimeCall::FellowshipSalary { .. }
| RuntimeCall::FellowshipTreasury { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Ambassador => matches!(
c,
RuntimeCall::AmbassadorCollective { .. } |
RuntimeCall::AmbassadorReferenda { .. } |
RuntimeCall::AmbassadorContent { .. } |
RuntimeCall::AmbassadorCore { .. } |
RuntimeCall::AmbassadorSalary { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::AmbassadorCollective { .. }
| RuntimeCall::AmbassadorReferenda { .. }
| RuntimeCall::AmbassadorContent { .. }
| RuntimeCall::AmbassadorCore { .. }
| RuntimeCall::AmbassadorSalary { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Secretary => matches!(
c,
RuntimeCall::SecretaryCollective { .. } |
RuntimeCall::SecretarySalary { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::SecretaryCollective { .. }
| RuntimeCall::SecretarySalary { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -44,8 +44,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -524,39 +524,39 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Broker => {
matches!(
c,
RuntimeCall::Broker { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::CoretimeRenewer => {
matches!(
c,
RuntimeCall::Broker(pezpallet_broker::Call::renew { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker(pezpallet_broker::Call::renew { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::OnDemandPurchaser => {
matches!(
c,
RuntimeCall::Broker(pezpallet_broker::Call::purchase_credit { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker(pezpallet_broker::Call::purchase_credit { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -44,8 +44,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -522,39 +522,39 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Broker => {
matches!(
c,
RuntimeCall::Broker { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::CoretimeRenewer => {
matches!(
c,
RuntimeCall::Broker(pezpallet_broker::Call::renew { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker(pezpallet_broker::Call::renew { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::OnDemandPurchaser => {
matches!(
c,
RuntimeCall::Broker(pezpallet_broker::Call::purchase_credit { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Broker(pezpallet_broker::Call::purchase_credit { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -43,8 +43,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -562,29 +562,29 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Identity => {
matches!(
c,
RuntimeCall::Identity { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Identity { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. }) |
RuntimeCall::Utility(..) |
RuntimeCall::Multisig { .. }
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. })
| RuntimeCall::Utility(..)
| RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -43,8 +43,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -477,29 +477,29 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Proxy(pezpallet_proxy::Call::reject_announcement { .. })
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
ProxyType::Identity => {
matches!(
c,
RuntimeCall::Identity { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::Identity { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
)
},
ProxyType::IdentityJudgement => matches!(
c,
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. }) |
RuntimeCall::Utility(..) |
RuntimeCall::Multisig { .. }
RuntimeCall::Identity(pezpallet_identity::Call::provide_judgement { .. })
| RuntimeCall::Utility(..)
| RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
RuntimeCall::CollatorSelection { .. }
| RuntimeCall::Utility { .. }
| RuntimeCall::Multisig { .. }
),
}
}
@@ -43,8 +43,9 @@ impl WeighAssets for AssetFilter {
WildFungibility::Fungible => weight,
// Magic number 2 has to do with the fact that we could have up to 2 times
// MaxAssetsIntoHolding in the worst-case scenario.
WildFungibility::NonFungible =>
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
WildFungibility::NonFungible => {
weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64)
},
},
AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
@@ -525,14 +525,17 @@ impl<
GovernanceOrigin::Location(location) if location == Location::here() => {
panic!("Location::here() not supported, use GovernanceOrigin::Origin instead")
},
GovernanceOrigin::Location(location) =>
execute_xcm(call, location, None).ensure_complete().map_err(Either::Right),
GovernanceOrigin::LocationAndDescendOrigin(location, descend_origin) =>
GovernanceOrigin::Location(location) => {
execute_xcm(call, location, None).ensure_complete().map_err(Either::Right)
},
GovernanceOrigin::LocationAndDescendOrigin(location, descend_origin) => {
execute_xcm(call, location, Some(descend_origin))
.ensure_complete()
.map_err(Either::Right),
GovernanceOrigin::Origin(origin) =>
call.dispatch(origin).map(|_| ()).map_err(|e| Either::Left(e.error)),
.map_err(Either::Right)
},
GovernanceOrigin::Origin(origin) => {
call.dispatch(origin).map(|_| ()).map_err(|e| Either::Left(e.error))
},
}
}
@@ -640,8 +643,9 @@ impl<
.into_iter()
.filter_map(|e| unwrap_xcmp_queue_event(e.event.encode()))
.find_map(|e| match e {
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } =>
Some(message_hash),
pezcumulus_pezpallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => {
Some(message_hash)
},
_ => None,
})
}
@@ -272,8 +272,8 @@ where
{
fn contains(asset: &Asset, origin: &Location) -> bool {
let loc = Origin::get();
&loc == origin &&
matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) }
&loc == origin
&& matches!(asset, Asset { id: AssetId(asset_loc), fun: Fungible(_a) }
if asset_loc.starts_with(&Prefix::get()))
}
}
@@ -331,8 +331,8 @@ impl<AssetLocation: Get<Location>, Origin: Get<Location>> ContainsPair<Asset, Lo
{
fn contains(asset: &Asset, origin: &Location) -> bool {
tracing::trace!(target: "xcm::contains", ?asset, ?origin, "AssetFromChain");
*origin == Origin::get() &&
matches!(asset.id.clone(), AssetId(id) if id == AssetLocation::get())
*origin == Origin::get()
&& matches!(asset.id.clone(), AssetId(id) if id == AssetLocation::get())
}
}
@@ -59,8 +59,9 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
};
let patch = match id.as_ref() {
pezsp_genesis_builder::DEV_RUNTIME_PRESET =>
genesis_fn(vec![Sr25519Keyring::Alice.public().into()]),
pezsp_genesis_builder::DEV_RUNTIME_PRESET => {
genesis_fn(vec![Sr25519Keyring::Alice.public().into()])
},
pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => genesis_fn(vec![
Sr25519Keyring::Alice.public().into(),
Sr25519Keyring::Bob.public().into(),
@@ -401,8 +401,8 @@ impl WeightToFeePolynomial for WeightToFee {
// in Pezkuwichain, extrinsic base weight (smallest non-zero weight) is mapped to 1
// MILLI_UNIT: in our template, we map to 1/10 of that, or 1/10 MILLI_UNIT
let p = YAP / 10;
let q = 100 *
Balance::from(
let q = 100
* Balance::from(
pezframe_support::weights::constants::ExtrinsicBaseWeight::get().ref_time(),
);
vec![WeightToFeeCoefficient {