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 3208f208c0
commit abc4c3989b
898 changed files with 8671 additions and 6432 deletions
@@ -441,7 +441,7 @@ impl BootnodeAdvertisement {
fn handle_dht_event(&mut self, event: DhtEvent) {
match event {
DhtEvent::StartedProviding(key) =>
DhtEvent::StartedProviding(key) => {
if Some(&key) == self.current_epoch_key.as_ref() {
debug!(
target: LOG_TARGET,
@@ -454,7 +454,8 @@ impl BootnodeAdvertisement {
"Successfully published provider for next epoch key {}",
hex::encode(key.as_ref()),
);
},
}
},
DhtEvent::StartProvidingFailed(key) => {
if Some(&key) == self.current_epoch_key.as_ref() {
debug!(
+5 -5
View File
@@ -180,9 +180,9 @@ impl BootnodeDiscovery {
/// Schedule bootnode discovery if needed. Returns `false` if the discovery event loop should be
/// terminated.
fn maybe_retry_discovery(&mut self) -> bool {
let discovery_in_progress = self.key_being_discovered.is_some() ||
!self.pending_responses.is_empty() ||
!self.find_node_queries.is_empty();
let discovery_in_progress = self.key_being_discovered.is_some()
|| !self.pending_responses.is_empty()
|| !self.find_node_queries.is_empty();
let discovery_scheduled = !self.pending_start_discovery.is_terminated();
if discovery_in_progress || discovery_scheduled {
@@ -310,8 +310,8 @@ impl BootnodeDiscovery {
match (response.genesis_hash, response.fork_id) {
(genesis_hash, fork_id)
if genesis_hash == self.teyrchain_genesis_hash &&
fork_id == self.teyrchain_fork_id => {},
if genesis_hash == self.teyrchain_genesis_hash
&& fork_id == self.teyrchain_fork_id => {},
(genesis_hash, fork_id) => {
warn!(
target: LOG_TARGET,
@@ -148,10 +148,11 @@ where
let paras_inherent_data = match paras_inherent_data {
Some(p) => p,
None =>
None => {
return Err(
format!("Could not create paras inherent data at {:?}", relay_parent).into()
),
)
},
};
let mut other_inherent_data = self
@@ -118,13 +118,14 @@ where
async move {
let mut collation_requests = match params.collation_request_receiver {
Some(receiver) => receiver,
None =>
None => {
pezcumulus_client_collator::relay_chain_driven::init(
params.collator_key,
params.para_id,
params.overseer_handle,
)
.await,
.await
},
};
let mut collator = {
@@ -225,8 +226,8 @@ where
//
// With https://github.com/pezkuwichain/pezkuwi-sdk/issues/127 this implementation will be
// obsolete and also the underlying issue will be fixed.
if last_processed_slot >= *claim.slot() &&
last_relay_chain_block < *relay_parent_header.number()
if last_processed_slot >= *claim.slot()
&& last_relay_chain_block < *relay_parent_header.number()
{
continue;
}
@@ -138,7 +138,7 @@ async fn check_validation_code_or_log(
};
match state_validation_code_hash {
Some(state) =>
Some(state) => {
if state != *local_validation_code_hash {
tracing::warn!(
target: super::LOG_TARGET,
@@ -148,7 +148,8 @@ async fn check_validation_code_or_log(
relay_validation_code_hash = ?state,
"Teyrchain code doesn't match validation code stored in the relay chain state.",
);
},
}
},
None => {
tracing::warn!(
target: super::LOG_TARGET,
@@ -183,8 +184,8 @@ async fn scheduling_lookahead(
)
.unwrap_or_default();
if teyrchain_host_runtime_api_version <
RuntimeApiRequest::SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT
if teyrchain_host_runtime_api_version
< RuntimeApiRequest::SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT
{
return None;
}
@@ -607,10 +607,11 @@ pub(crate) async fn determine_core<H: HeaderT, RI: RelayChainInterface + 'static
} else {
match extract_relay_parent(para_parent.digest()) {
Some(last_relay_parent) => last_relay_parent != relay_parent.hash(),
None =>
None => {
rpsr_digest::extract_relay_parent_storage_root(para_parent.digest())
.ok_or(())?
.0 != *relay_parent.state_root(),
.0 != *relay_parent.state_root()
},
}
};
@@ -101,8 +101,8 @@ fn compute_next_wake_up_time(
// we should still produce two blocks if we are scheduled on every relay block.
let mut block_production_interval = min(para_slot_duration.as_duration(), relay_slot_duration);
if assigned_core_num > para_slots_per_relay_block &&
para_slot_duration.as_duration() >= relay_slot_duration
if assigned_core_num > para_slots_per_relay_block
&& para_slot_duration.as_duration() >= relay_slot_duration
{
block_production_interval =
max(relay_slot_duration / assigned_core_num, BLOCK_PRODUCTION_MINIMUM_INTERVAL_MS);
@@ -204,8 +204,8 @@ fn adjust_authoring_duration(
// without issues.
// - Block 11: next slot change in 0.993s - skipped by the deadline
// - Block 12: next slot change in 0.493s - skipped by the deadline
if authoring_duration <
BLOCK_PRODUCTION_MINIMUM_INTERVAL_MS.saturating_sub(BLOCK_PRODUCTION_THRESHOLD_MS)
if authoring_duration
< BLOCK_PRODUCTION_MINIMUM_INTERVAL_MS.saturating_sub(BLOCK_PRODUCTION_THRESHOLD_MS)
{
tracing::debug!(
target: LOG_TARGET,
@@ -233,9 +233,9 @@ fn time_until_next_attempt(
) -> (Duration, Timestamp) {
let now = now.as_millis().saturating_sub(offset.as_millis());
let next_slot_time = ((now + block_production_interval.as_millis()) /
block_production_interval.as_millis()) *
block_production_interval.as_millis();
let next_slot_time = ((now + block_production_interval.as_millis())
/ block_production_interval.as_millis())
* block_production_interval.as_millis();
let remaining_millis = next_slot_time - now;
(Duration::from_millis(remaining_millis as u64), Timestamp::from(next_slot_time as u64))
}
@@ -177,8 +177,8 @@ where
let relay_parent =
match CumulusDigestItem::find_relay_block_identifier(pre_header.digest()) {
None => Default::default(),
Some(RelayBlockIdentifier::ByHash(h)) |
Some(RelayBlockIdentifier::ByStorageRoot {
Some(RelayBlockIdentifier::ByHash(h))
| Some(RelayBlockIdentifier::ByStorageRoot {
storage_root: h, ..
}) => h,
};
@@ -219,11 +219,12 @@ where
post_hash, slot
));
},
Err(e) =>
Err(e) => {
return Err(format!(
"Rejecting block ({:?}) with invalid seal ({:?})",
post_hash, e
)),
))
},
}
}
@@ -396,9 +396,9 @@ pub fn search_child_branches_for_parents<Block: BlockT>(
for child in backend.blockchain().children(hash).ok().into_iter().flatten() {
tracing::trace!(target: PARENT_SEARCH_LOG_TARGET, ?child, child_depth, ?pending_distance, "Looking at child.");
let aligned_with_pending = parent_aligned_with_pending &&
(pending_distance.map_or(true, |dist| child_depth > dist) ||
is_child_pending(child));
let aligned_with_pending = parent_aligned_with_pending
&& (pending_distance.map_or(true, |dist| child_depth > dist)
|| is_child_pending(child));
if ignore_alternative_branches && !aligned_with_pending {
tracing::trace!(target: PARENT_SEARCH_LOG_TARGET, ?child, "Child is not aligned with pending block.");
+5 -4
View File
@@ -290,8 +290,8 @@ where
// If the relay chain runtime does not support the new runtime API, fallback to the
// deprecated one.
let candidate_receipts = if teyrchain_host_runtime_api_version <
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
let candidate_receipts = if teyrchain_host_runtime_api_version
< RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
#[allow(deprecated)]
relay_chain_interface
@@ -389,11 +389,12 @@ where
let block_announce_data = match BlockAnnounceData::decode_all(&mut data.as_slice()) {
Ok(r) => r,
Err(err) =>
Err(err) => {
return Err(Box::new(BlockAnnounceError(format!(
"Can not decode the `BlockAnnounceData`: {:?}",
err
))) as Box<_>),
))) as Box<_>)
},
};
if let Err(e) = block_announce_data.validate(header_encoded) {
+7 -6
View File
@@ -166,8 +166,8 @@ impl RelayChainInterface for DummyRelayChainInterface {
_: PHash,
_: ParaId,
) -> RelayChainResult<Option<CommittedCandidateReceiptV2>> {
if self.data.lock().runtime_version >=
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
if self.data.lock().runtime_version
>= RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidates_pending_availability instead");
}
@@ -184,8 +184,8 @@ impl RelayChainInterface for DummyRelayChainInterface {
_: PHash,
_: ParaId,
) -> RelayChainResult<Vec<CommittedCandidateReceiptV2>> {
if self.data.lock().runtime_version <
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
if self.data.lock().runtime_version
< RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidate_pending_availability instead");
}
@@ -289,12 +289,13 @@ impl RelayChainInterface for DummyRelayChainInterface {
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
let hash = match block_id {
BlockId::Hash(hash) => hash,
BlockId::Number(num) =>
BlockId::Number(num) => {
if let Some(hash) = self.relay_client.hash(num)? {
hash
} else {
return Ok(None);
},
}
},
};
let header = self.relay_client.header(hash)?;
+3 -2
View File
@@ -390,7 +390,7 @@ where
self.candidates_in_retry.remove(&block_hash);
pov
},
None =>
None => {
if self.candidates_in_retry.insert(block_hash) {
tracing::debug!(target: LOG_TARGET, ?block_hash, "Recovery failed, retrying.");
self.candidate_recovery_queue.push_recovery(block_hash);
@@ -404,7 +404,8 @@ where
self.candidates_in_retry.remove(&block_hash);
self.reset_candidate(block_hash);
return;
},
}
},
};
let raw_block_data =
+4 -4
View File
@@ -390,8 +390,8 @@ impl RelayChainInterface for Relaychain {
hash: PHash,
_: ParaId,
) -> RelayChainResult<Option<CommittedCandidateReceipt>> {
if self.inner.lock().expect("Poisoned lock").runtime_version >=
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
if self.inner.lock().expect("Poisoned lock").runtime_version
>= RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidates_pending_availability instead");
}
@@ -413,8 +413,8 @@ impl RelayChainInterface for Relaychain {
hash: PHash,
_: ParaId,
) -> RelayChainResult<Vec<CommittedCandidateReceipt>> {
if self.inner.lock().expect("Poisoned lock").runtime_version <
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
if self.inner.lock().expect("Poisoned lock").runtime_version
< RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
panic!("Should have used candidate_pending_availability instead");
}
@@ -109,12 +109,13 @@ impl RelayChainInterface for RelayChainInProcessInterface {
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
let hash = match block_id {
BlockId::Hash(hash) => hash,
BlockId::Number(num) =>
BlockId::Number(num) => {
if let Some(hash) = self.full_client.hash(num)? {
hash
} else {
return Ok(None);
},
}
},
};
let header = self.full_client.header(hash)?;
@@ -109,19 +109,21 @@ async fn build_interface(
let blockchain_rpc_client = Arc::new(BlockChainRpcClient::new(client.clone()));
let collator_node =
match pezkuwi_config.network.network_backend {
pezsc_network::config::NetworkBackendType::Libp2p =>
pezsc_network::config::NetworkBackendType::Libp2p => {
new_minimal_relay_chain::<
RelayBlock,
pezsc_network::NetworkWorker<RelayBlock, RelayHash>,
>(pezkuwi_config, collator_pair.clone(), blockchain_rpc_client)
.await?,
pezsc_network::config::NetworkBackendType::Litep2p =>
.await?
},
pezsc_network::config::NetworkBackendType::Litep2p => {
new_minimal_relay_chain::<RelayBlock, pezsc_network::Litep2pNetworkBackend>(
pezkuwi_config,
collator_pair.clone(),
blockchain_rpc_client,
)
.await?,
.await?
},
};
task_manager.add_child(collator_node.task_manager);
Ok((
@@ -110,8 +110,8 @@ pub(crate) fn build_collator_network<Network: NetworkBackend<Block, Hash>>(
}
fn adjust_network_config_light_in_peers(config: &mut NetworkConfiguration) {
let light_client_in_peers = (config.default_peers_set.in_peers +
config.default_peers_set.out_peers)
let light_client_in_peers = (config.default_peers_set.in_peers
+ config.default_peers_set.out_peers)
.saturating_sub(config.default_peers_set_num_full);
if light_client_in_peers > 0 {
tracing::debug!(target: crate::LOG_TARGET, "Detected {light_client_in_peers} peer slots for light clients. Since this minimal node does support\
@@ -125,8 +125,8 @@ async fn connect_next_available_rpc_server(
if current_iteration > prev_iteration {
// Safe conversion given we convert positive i32s which are lower than u64::MAX.
tokio::time::sleep(Duration::from_millis(
DEFAULT_SLEEP_TIME_MS_BETWEEN_RETRIES *
DEFAULT_SLEEP_EXP_BACKOFF_BETWEEN_RETRIES.pow(prev_iteration) as u64,
DEFAULT_SLEEP_TIME_MS_BETWEEN_RETRIES
* DEFAULT_SLEEP_EXP_BACKOFF_BETWEEN_RETRIES.pow(prev_iteration) as u64,
))
.await;
prev_iteration = current_iteration;
@@ -78,8 +78,8 @@ pub async fn pending_candidates(
// If the relay chain runtime does not support the new runtime API, fallback to the
// deprecated one.
let pending_availability_result = if teyrchain_host_runtime_api_version <
RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
let pending_availability_result = if teyrchain_host_runtime_api_version
< RuntimeApiRequest::CANDIDATES_PENDING_AVAILABILITY_RUNTIME_REQUIREMENT
{
#[allow(deprecated)]
client
+3 -2
View File
@@ -244,14 +244,15 @@ pub async fn build_relay_chain_interface(
task_manager,
hwbench,
),
pezcumulus_client_cli::RelayChainMode::ExternalRpc(rpc_target_urls) =>
pezcumulus_client_cli::RelayChainMode::ExternalRpc(rpc_target_urls) => {
build_minimal_relay_chain_node_with_rpc(
relay_chain_config,
teyrchain_config.prometheus_registry(),
task_manager,
rpc_target_urls,
)
.await,
.await
},
}
}
@@ -88,10 +88,12 @@ fn new_node_spec(
Ok(match runtime {
Runtime::Omni(block_number, consensus) => match (block_number, consensus) {
(BlockNumber::U32, Consensus::Aura(aura_id)) =>
new_aura_node_spec::<Block<u32>>(aura_id, extra_args),
(BlockNumber::U64, Consensus::Aura(aura_id)) =>
new_aura_node_spec::<Block<u64>>(aura_id, extra_args),
(BlockNumber::U32, Consensus::Aura(aura_id)) => {
new_aura_node_spec::<Block<u32>>(aura_id, extra_args)
},
(BlockNumber::U64, Consensus::Aura(aura_id)) => {
new_aura_node_spec::<Block<u64>>(aura_id, extra_args)
},
},
})
}
@@ -188,8 +190,9 @@ where
node.prepare_revert_cmd(config, cmd)
})
},
Some(Subcommand::ChainSpecBuilder(cmd)) =>
cmd.run().map_err(|err| pezsc_cli::Error::Application(err.into())),
Some(Subcommand::ChainSpecBuilder(cmd)) => {
cmd.run().map_err(|err| pezsc_cli::Error::Application(err.into()))
},
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
@@ -18,12 +18,12 @@
use codec::Decode;
use pezcumulus_client_service::TeyrchainHostFunctions;
use pezkuwi_subxt_metadata::Metadata;
use pezsc_chain_spec::ChainSpec;
use pezsc_executor::WasmExecutor;
use pezsc_runtime_utilities::fetch_latest_metadata_from_code_blob;
use scale_info::{form::PortableForm, TypeDef, TypeDefPrimitive};
use std::fmt::Display;
use pezkuwi_subxt_metadata::Metadata;
/// Expected teyrchain system pezpallet runtime type name.
pub const DEFAULT_TEYRCHAIN_SYSTEM_PALLET_NAME: &str = "TeyrchainSystem";
@@ -613,22 +613,24 @@ where
node_extra_args: NodeExtraArgs,
) -> Pin<Box<dyn Future<Output = pezsc_service::error::Result<TaskManager>>>> {
match teyrchain_config.network.network_backend {
pezsc_network::config::NetworkBackendType::Libp2p =>
pezsc_network::config::NetworkBackendType::Libp2p => {
<Self as NodeSpec>::start_node::<pezsc_network::NetworkWorker<_, _>>(
teyrchain_config,
pezkuwi_config,
collator_options,
hwbench,
node_extra_args,
),
pezsc_network::config::NetworkBackendType::Litep2p =>
)
},
pezsc_network::config::NetworkBackendType::Litep2p => {
<Self as NodeSpec>::start_node::<pezsc_network::Litep2pNetworkBackend>(
teyrchain_config,
pezkuwi_config,
collator_options,
hwbench,
node_extra_args,
),
)
},
}
}
}
@@ -51,10 +51,12 @@ impl FromStr for BridgeHubRuntimeType {
zagros::BRIDGE_HUB_ZAGROS_LOCAL => Ok(BridgeHubRuntimeType::ZagrosLocal),
zagros::BRIDGE_HUB_ZAGROS_DEVELOPMENT => Ok(BridgeHubRuntimeType::ZagrosDevelopment),
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN => Ok(BridgeHubRuntimeType::Pezkuwichain),
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN_LOCAL =>
Ok(BridgeHubRuntimeType::PezkuwichainLocal),
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN_DEVELOPMENT =>
Ok(BridgeHubRuntimeType::PezkuwichainDevelopment),
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN_LOCAL => {
Ok(BridgeHubRuntimeType::PezkuwichainLocal)
},
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN_DEVELOPMENT => {
Ok(BridgeHubRuntimeType::PezkuwichainDevelopment)
},
_ => Err(format!("Value '{}' is not configured yet", value)),
}
}
@@ -96,14 +98,15 @@ impl BridgeHubRuntimeType {
|_| (),
ChainType::Local,
))),
BridgeHubRuntimeType::PezkuwichainDevelopment =>
BridgeHubRuntimeType::PezkuwichainDevelopment => {
Ok(Box::new(pezkuwichain::local_config(
pezkuwichain::BRIDGE_HUB_PEZKUWICHAIN_DEVELOPMENT,
"Pezkuwichain BridgeHub Development",
"pezkuwichain-dev",
|_| (),
ChainType::Development,
))),
)))
},
other => Err(std::format!("No default config present for {:?}", other)),
}
}
@@ -53,8 +53,9 @@ impl FromStr for CoretimeRuntimeType {
pezkuwi::CORETIME_PEZKUWI_LOCAL => Ok(CoretimeRuntimeType::PezkuwiLocal),
pezkuwichain::CORETIME_PEZKUWICHAIN => Ok(CoretimeRuntimeType::Pezkuwichain),
pezkuwichain::CORETIME_PEZKUWICHAIN_LOCAL => Ok(CoretimeRuntimeType::PezkuwichainLocal),
pezkuwichain::CORETIME_PEZKUWICHAIN_DEVELOPMENT =>
Ok(CoretimeRuntimeType::PezkuwichainDevelopment),
pezkuwichain::CORETIME_PEZKUWICHAIN_DEVELOPMENT => {
Ok(CoretimeRuntimeType::PezkuwichainDevelopment)
},
zagros::CORETIME_ZAGROS => Ok(CoretimeRuntimeType::Zagros),
zagros::CORETIME_ZAGROS_LOCAL => Ok(CoretimeRuntimeType::ZagrosLocal),
zagros::CORETIME_ZAGROS_DEVELOPMENT => Ok(CoretimeRuntimeType::ZagrosDevelopment),
@@ -72,8 +73,9 @@ impl From<CoretimeRuntimeType> for &str {
CoretimeRuntimeType::PezkuwiLocal => pezkuwi::CORETIME_PEZKUWI_LOCAL,
CoretimeRuntimeType::Pezkuwichain => pezkuwichain::CORETIME_PEZKUWICHAIN,
CoretimeRuntimeType::PezkuwichainLocal => pezkuwichain::CORETIME_PEZKUWICHAIN_LOCAL,
CoretimeRuntimeType::PezkuwichainDevelopment =>
pezkuwichain::CORETIME_PEZKUWICHAIN_DEVELOPMENT,
CoretimeRuntimeType::PezkuwichainDevelopment => {
pezkuwichain::CORETIME_PEZKUWICHAIN_DEVELOPMENT
},
CoretimeRuntimeType::Zagros => zagros::CORETIME_ZAGROS,
CoretimeRuntimeType::ZagrosLocal => zagros::CORETIME_ZAGROS_LOCAL,
CoretimeRuntimeType::ZagrosDevelopment => zagros::CORETIME_ZAGROS_DEVELOPMENT,
@@ -84,16 +86,16 @@ impl From<CoretimeRuntimeType> for &str {
impl From<CoretimeRuntimeType> for ChainType {
fn from(runtime_type: CoretimeRuntimeType) -> Self {
match runtime_type {
CoretimeRuntimeType::Kusama |
CoretimeRuntimeType::Pezkuwi |
CoretimeRuntimeType::Pezkuwichain |
CoretimeRuntimeType::Zagros => ChainType::Live,
CoretimeRuntimeType::KusamaLocal |
CoretimeRuntimeType::PezkuwiLocal |
CoretimeRuntimeType::PezkuwichainLocal |
CoretimeRuntimeType::ZagrosLocal => ChainType::Local,
CoretimeRuntimeType::PezkuwichainDevelopment |
CoretimeRuntimeType::ZagrosDevelopment => ChainType::Development,
CoretimeRuntimeType::Kusama
| CoretimeRuntimeType::Pezkuwi
| CoretimeRuntimeType::Pezkuwichain
| CoretimeRuntimeType::Zagros => ChainType::Live,
CoretimeRuntimeType::KusamaLocal
| CoretimeRuntimeType::PezkuwiLocal
| CoretimeRuntimeType::PezkuwichainLocal
| CoretimeRuntimeType::ZagrosLocal => ChainType::Local,
CoretimeRuntimeType::PezkuwichainDevelopment
| CoretimeRuntimeType::ZagrosDevelopment => ChainType::Development,
}
}
}
@@ -112,17 +114,21 @@ impl CoretimeRuntimeType {
CoretimeRuntimeType::Pezkuwichain => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/coretime-pezkuwichain.json")[..],
)?)),
CoretimeRuntimeType::PezkuwichainLocal =>
Ok(Box::new(pezkuwichain::local_config(*self, "pezkuwichain-local"))),
CoretimeRuntimeType::PezkuwichainDevelopment =>
Ok(Box::new(pezkuwichain::local_config(*self, "pezkuwichain-dev"))),
CoretimeRuntimeType::PezkuwichainLocal => {
Ok(Box::new(pezkuwichain::local_config(*self, "pezkuwichain-local")))
},
CoretimeRuntimeType::PezkuwichainDevelopment => {
Ok(Box::new(pezkuwichain::local_config(*self, "pezkuwichain-dev")))
},
CoretimeRuntimeType::Zagros => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../../teyrchains/chain-specs/coretime-zagros.json")[..],
)?)),
CoretimeRuntimeType::ZagrosLocal =>
Ok(Box::new(zagros::local_config(*self, "zagros-local"))),
CoretimeRuntimeType::ZagrosDevelopment =>
Ok(Box::new(zagros::local_config(*self, "zagros-dev"))),
CoretimeRuntimeType::ZagrosLocal => {
Ok(Box::new(zagros::local_config(*self, "zagros-local")))
},
CoretimeRuntimeType::ZagrosDevelopment => {
Ok(Box::new(zagros::local_config(*self, "zagros-dev")))
},
other => Err(std::format!(
"No default config present for {:?}, you should provide a chain-spec as json file!",
other
@@ -58,8 +58,9 @@ impl LoadSpec for ChainSpecLoader {
fn load_spec(&self, id: &str) -> Result<Box<dyn ChainSpec>, String> {
Ok(match id {
// - Default-like
"staging" =>
Box::new(pezkuwichain_teyrchain::pezstaging_pezkuwichain_teyrchain_local_config()),
"staging" => {
Box::new(pezkuwichain_teyrchain::pezstaging_pezkuwichain_teyrchain_local_config())
},
"tick" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/tick.json")[..],
)?),
@@ -81,25 +82,31 @@ impl LoadSpec for ChainSpecLoader {
)?),
// -- Asset Hub Pezkuwichain
"asset-hub-pezkuwichain-dev" =>
Box::new(asset_hubs::asset_hub_pezkuwichain_development_config()),
"asset-hub-pezkuwichain-local" =>
Box::new(asset_hubs::asset_hub_pezkuwichain_local_config()),
"asset-hub-pezkuwichain-dev" => {
Box::new(asset_hubs::asset_hub_pezkuwichain_development_config())
},
"asset-hub-pezkuwichain-local" => {
Box::new(asset_hubs::asset_hub_pezkuwichain_local_config())
},
// the chain spec as used for generating the upgrade genesis values
"asset-hub-pezkuwichain-genesis" =>
Box::new(asset_hubs::asset_hub_pezkuwichain_genesis_config()),
"asset-hub-pezkuwichain-genesis" => {
Box::new(asset_hubs::asset_hub_pezkuwichain_genesis_config())
},
"asset-hub-pezkuwichain" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/asset-hub-pezkuwichain.json")[..],
)?),
// -- Asset Hub Zagros
"asset-hub-zagros-dev" | "westmint-dev" =>
Box::new(asset_hubs::asset_hub_zagros_development_config()),
"asset-hub-zagros-local" | "westmint-local" =>
Box::new(asset_hubs::asset_hub_zagros_local_config()),
"asset-hub-zagros-dev" | "westmint-dev" => {
Box::new(asset_hubs::asset_hub_zagros_development_config())
},
"asset-hub-zagros-local" | "westmint-local" => {
Box::new(asset_hubs::asset_hub_zagros_local_config())
},
// the chain spec as used for generating the upgrade genesis values
"asset-hub-zagros-genesis" | "westmint-genesis" =>
Box::new(asset_hubs::asset_hub_zagros_config()),
"asset-hub-zagros-genesis" | "westmint-genesis" => {
Box::new(asset_hubs::asset_hub_zagros_config())
},
// the shell-based chain spec as used for syncing
"asset-hub-zagros" | "westmint" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/asset-hub-zagros.json")[..],
@@ -111,8 +118,9 @@ impl LoadSpec for ChainSpecLoader {
)?),
// -- Zagros Collectives
"collectives-zagros-dev" =>
Box::new(collectives::collectives_zagros_development_config()),
"collectives-zagros-dev" => {
Box::new(collectives::collectives_zagros_development_config())
},
"collectives-zagros-local" => Box::new(collectives::collectives_zagros_local_config()),
"collectives-zagros" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/collectives-zagros.json")[..],
@@ -121,18 +129,22 @@ impl LoadSpec for ChainSpecLoader {
// -- BridgeHub
bridge_like_id
if bridge_like_id.starts_with(bridge_hubs::BridgeHubRuntimeType::ID_PREFIX) =>
{
bridge_like_id
.parse::<bridge_hubs::BridgeHubRuntimeType>()
.expect("invalid value")
.load_config()?,
.load_config()?
},
// -- Coretime
coretime_like_id
if coretime_like_id.starts_with(coretime::CoretimeRuntimeType::ID_PREFIX) =>
{
coretime_like_id
.parse::<coretime::CoretimeRuntimeType>()
.expect("invalid value")
.load_config()?,
.load_config()?
},
// -- Penpal
id if id.starts_with("penpal-pezkuwichain") => {
@@ -197,11 +209,12 @@ impl LoadSpec for ChainSpecLoader {
},
// -- People
people_like_id if people_like_id.starts_with(people::PeopleRuntimeType::ID_PREFIX) =>
people_like_id if people_like_id.starts_with(people::PeopleRuntimeType::ID_PREFIX) => {
people_like_id
.parse::<people::PeopleRuntimeType>()
.expect("invalid value")
.load_config()?,
.load_config()?
},
// -- Fallback (generic chainspec)
"" => {
@@ -236,12 +249,12 @@ impl LegacyRuntime {
if id.starts_with("asset-hub-pezkuwi") | id.starts_with("statemint") {
LegacyRuntime::AssetHubPezkuwi
} else if id.starts_with("asset-hub-kusama") |
id.starts_with("statemine") |
id.starts_with("asset-hub-pezkuwichain") |
id.starts_with("rockmine") |
id.starts_with("asset-hub-zagros") |
id.starts_with("westmint")
} else if id.starts_with("asset-hub-kusama")
| id.starts_with("statemine")
| id.starts_with("asset-hub-pezkuwichain")
| id.starts_with("rockmine")
| id.starts_with("asset-hub-zagros")
| id.starts_with("westmint")
{
LegacyRuntime::AssetHub
} else if id.starts_with("penpal") {
@@ -278,17 +291,19 @@ impl RuntimeResolverT for RuntimeResolver {
fn runtime(&self, chain_spec: &dyn ChainSpec) -> pezsc_cli::Result<Runtime> {
let legacy_runtime = LegacyRuntime::from_id(chain_spec.id());
Ok(match legacy_runtime {
LegacyRuntime::AssetHubPezkuwi =>
Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Ed25519)),
LegacyRuntime::AssetHub |
LegacyRuntime::BridgeHub(_) |
LegacyRuntime::Collectives |
LegacyRuntime::Coretime(_) |
LegacyRuntime::People(_) |
LegacyRuntime::Glutton |
LegacyRuntime::Penpal |
LegacyRuntime::Omni =>
Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Sr25519)),
LegacyRuntime::AssetHubPezkuwi => {
Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Ed25519))
},
LegacyRuntime::AssetHub
| LegacyRuntime::BridgeHub(_)
| LegacyRuntime::Collectives
| LegacyRuntime::Coretime(_)
| LegacyRuntime::People(_)
| LegacyRuntime::Glutton
| LegacyRuntime::Penpal
| LegacyRuntime::Omni => {
Runtime::Omni(BlockNumber::U32, Consensus::Aura(AuraConsensusId::Sr25519))
},
})
}
}
@@ -44,8 +44,9 @@ impl FromStr for PeopleRuntimeType {
pezkuwi::PEOPLE_PEZKUWI_LOCAL => Ok(PeopleRuntimeType::PezkuwiLocal),
pezkuwichain::PEOPLE_PEZKUWICHAIN => Ok(PeopleRuntimeType::Pezkuwichain),
pezkuwichain::PEOPLE_PEZKUWICHAIN_LOCAL => Ok(PeopleRuntimeType::PezkuwichainLocal),
pezkuwichain::PEOPLE_PEZKUWICHAIN_DEVELOPMENT =>
Ok(PeopleRuntimeType::PezkuwichainDevelopment),
pezkuwichain::PEOPLE_PEZKUWICHAIN_DEVELOPMENT => {
Ok(PeopleRuntimeType::PezkuwichainDevelopment)
},
zagros::PEOPLE_ZAGROS => Ok(PeopleRuntimeType::Zagros),
zagros::PEOPLE_ZAGROS_LOCAL => Ok(PeopleRuntimeType::ZagrosLocal),
zagros::PEOPLE_ZAGROS_DEVELOPMENT => Ok(PeopleRuntimeType::ZagrosDevelopment),
@@ -274,8 +274,8 @@ mod benchmarks {
let caller = CandidateList::<T>::get()[0].who.clone();
v2::whitelist!(caller);
let bond_amount: BalanceOf<T> = <T as pezpallet::Config>::Currency::minimum_balance() +
<T as pezpallet::Config>::Currency::minimum_balance();
let bond_amount: BalanceOf<T> = <T as pezpallet::Config>::Currency::minimum_balance()
+ <T as pezpallet::Config>::Currency::minimum_balance();
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), bond_amount);
@@ -284,8 +284,8 @@ mod benchmarks {
Event::CandidateBondUpdated { account_id: caller, deposit: bond_amount }.into(),
);
assert!(
CandidateList::<T>::get().iter().last().unwrap().deposit ==
<T as pezpallet::Config>::Currency::minimum_balance() * 2u32.into()
CandidateList::<T>::get().iter().last().unwrap().deposit
== <T as pezpallet::Config>::Currency::minimum_balance() * 2u32.into()
);
Ok(())
}
@@ -352,8 +352,8 @@ pub mod pezpallet {
fn integrity_test() {
assert!(T::MinEligibleCollators::get() > 0, "chain must require at least one collator");
assert!(
T::MaxInvulnerables::get().saturating_add(T::MaxCandidates::get()) >=
T::MinEligibleCollators::get(),
T::MaxInvulnerables::get().saturating_add(T::MaxCandidates::get())
>= T::MinEligibleCollators::get(),
"invulnerables and candidates must be able to satisfy collator demand"
);
}
@@ -388,8 +388,8 @@ pub mod pezpallet {
if new.is_empty() {
// Casting `u32` to `usize` should be safe on all machines running this.
ensure!(
CandidateList::<T>::decode_len().unwrap_or_default() >=
T::MinEligibleCollators::get() as usize,
CandidateList::<T>::decode_len().unwrap_or_default()
>= T::MinEligibleCollators::get() as usize,
Error::<T>::TooFewEligibleCollators
);
}
@@ -696,8 +696,8 @@ pub mod pezpallet {
} else if new_deposit < old_deposit {
// Casting `u32` to `usize` should be safe on all machines running this.
ensure!(
idx.saturating_add(DesiredCandidates::<T>::get() as usize) <
candidate_count,
idx.saturating_add(DesiredCandidates::<T>::get() as usize)
< candidate_count,
Error::<T>::InvalidUnreserve
);
T::Currency::unreserve(&who, old_deposit - new_deposit);
@@ -80,8 +80,9 @@ impl Parse for Input {
fn crate_() -> Result<Ident, Error> {
match crate_name("pezcumulus-pezpallet-teyrchain-system") {
Ok(FoundCrate::Itself) =>
Ok(syn::Ident::new("pezcumulus_pezpallet_teyrchain_system", Span::call_site())),
Ok(FoundCrate::Itself) => {
Ok(syn::Ident::new("pezcumulus_pezpallet_teyrchain_system", Span::call_site()))
},
Ok(FoundCrate::Name(name)) => Ok(Ident::new(&name, Span::call_site())),
Err(e) => Err(Error::new(Span::call_site(), e)),
}
@@ -1705,7 +1705,7 @@ impl<T: Config> UpwardMessageSender for Pezpallet<T> {
const MAX_CODE_SIZE: u32 = 3 * 1024 * 1024;
HostConfiguration::<T>::mutate(|cfg| match cfg {
Some(cfg) => cfg.max_upward_message_size = MAX_UPWARD_MESSAGE_SIZE,
None =>
None => {
*cfg = Some(AbridgedHostConfiguration {
max_code_size: MAX_CODE_SIZE,
max_head_data_size: 32 * 1024,
@@ -1720,7 +1720,8 @@ impl<T: Config> UpwardMessageSender for Pezpallet<T> {
allowed_ancestry_len: 0,
max_candidate_depth: 0,
},
}),
})
},
})
}
}
@@ -166,10 +166,10 @@ impl XcmpMessageSource for FromThreadLocal {
let msg_len = m.1.len();
if !ids.contains(&m.0) &&
taken_messages < maximum_channels &&
msg_len <= max_size_ever &&
taken_bytes + msg_len <= max_size_now
if !ids.contains(&m.0)
&& taken_messages < maximum_channels
&& msg_len <= max_size_ever
&& taken_bytes + msg_len <= max_size_now
{
ids.insert(m.0);
taken_messages += 1;
@@ -43,15 +43,17 @@ impl<'a, H: trie_db::Hasher> trie_db::TrieRecorder<H::Out> for SizeOnlyRecorder<
fn record(&mut self, access: TrieAccess<'_, H::Out>) {
let mut encoded_size_update = 0;
match access {
TrieAccess::NodeOwned { hash, node_owned } =>
TrieAccess::NodeOwned { hash, node_owned } => {
if self.seen_nodes.insert(hash) {
let node = node_owned.to_encoded::<NodeCodec<H>>();
encoded_size_update += node.encoded_size();
},
TrieAccess::EncodedNode { hash, encoded_node } =>
}
},
TrieAccess::EncodedNode { hash, encoded_node } => {
if self.seen_nodes.insert(hash) {
encoded_size_update += encoded_node.encoded_size();
},
}
},
TrieAccess::Value { hash, value, full_key } => {
if self.seen_nodes.insert(hash) {
encoded_size_update += value.encoded_size();
@@ -584,8 +584,8 @@ fn test_series() {
block_weight_pre_dispatch: Weight::from_parts(1000, 1000),
mock_ext_refund: Weight::from_parts(0, 0),
assert_post_info_weight: None,
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1100, 1300 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1100, 1300 + LEN as u64),
},
// some tx ext refund is ignored, because post info is None.
TestCfg {
@@ -597,8 +597,8 @@ fn test_series() {
block_weight_pre_dispatch: Weight::from_parts(1000, 1000),
mock_ext_refund: Weight::from_parts(20, 20),
assert_post_info_weight: None,
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1100, 1300 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1100, 1300 + LEN as u64),
},
// some tx ext refund is ignored on proof size because lower than actual measure.
TestCfg {
@@ -610,8 +610,8 @@ fn test_series() {
block_weight_pre_dispatch: Weight::from_parts(1000, 1000),
mock_ext_refund: Weight::from_parts(20, 20),
assert_post_info_weight: Some(Weight::from_parts(80, 300)),
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1080, 1300 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1080, 1300 + LEN as u64),
},
// post info doesn't double refund the call and is missing some.
TestCfg {
@@ -624,8 +624,8 @@ fn test_series() {
mock_ext_refund: Weight::from_parts(20, 20),
// 50 are missed in pov because 100 is unspent in post info but it should be only 50.
assert_post_info_weight: Some(Weight::from_parts(40, 200)),
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1040, 1250 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1040, 1250 + LEN as u64),
},
// post info doesn't double refund the call and is accurate.
TestCfg {
@@ -637,8 +637,8 @@ fn test_series() {
block_weight_pre_dispatch: Weight::from_parts(1000, 1000),
mock_ext_refund: Weight::from_parts(20, 20),
assert_post_info_weight: Some(Weight::from_parts(40, 150)),
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1040, 1150 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1040, 1150 + LEN as u64),
},
// post info doesn't double refund the call and is accurate. Even if mock ext is refunding
// too much.
@@ -651,8 +651,8 @@ fn test_series() {
block_weight_pre_dispatch: Weight::from_parts(1000, 1000),
mock_ext_refund: Weight::from_parts(20, 300),
assert_post_info_weight: Some(Weight::from_parts(40, 150)),
assert_block_weight_post_dispatch: base_extrinsic +
Weight::from_parts(1040, 1150 + LEN as u64),
assert_block_weight_post_dispatch: base_extrinsic
+ Weight::from_parts(1040, 1150 + LEN as u64),
},
];
@@ -1034,11 +1034,11 @@ fn test_ref_time_weight_reclaim() {
pezframe_system::BlockWeight::<Test>::get()
.get(DispatchClass::Normal)
.ref_time(),
block_pre_dispatch +
base_extrinsic.ref_time() +
bench_post_dispatch_actual +
bench_mock_ext_weight -
bench_mock_ext_refund,
block_pre_dispatch
+ base_extrinsic.ref_time()
+ bench_post_dispatch_actual
+ bench_mock_ext_weight
- bench_mock_ext_refund,
);
assert_eq!(
pezframe_system::ExtrinsicWeightReclaimed::<Test>::get().ref_time(),
+11 -9
View File
@@ -442,9 +442,9 @@ impl QueueConfigData {
///
/// Should be called prior to accepting this as new config.
pub fn validate<T: crate::Config>(&self) -> pezsp_runtime::DispatchResult {
if self.resume_threshold < self.suspend_threshold &&
self.suspend_threshold <= self.drop_threshold &&
self.resume_threshold > 0
if self.resume_threshold < self.suspend_threshold
&& self.suspend_threshold <= self.drop_threshold
&& self.resume_threshold > 0
{
Ok(())
} else {
@@ -946,8 +946,8 @@ impl<T: Config> XcmpMessageHandler for Pezpallet<T> {
}
}
},
XcmpMessageFormat::ConcatenatedVersionedXcm |
XcmpMessageFormat::ConcatenatedOpaqueVersionedXcm => {
XcmpMessageFormat::ConcatenatedVersionedXcm
| XcmpMessageFormat::ConcatenatedOpaqueVersionedXcm => {
let encoding = match format {
XcmpMessageFormat::ConcatenatedVersionedXcm => XcmEncoding::Simple,
XcmpMessageFormat::ConcatenatedOpaqueVersionedXcm => XcmEncoding::Double,
@@ -1223,10 +1223,12 @@ impl<T: Config> InspectMessageQueues for Pezpallet<T> {
let mut decoded_messages = Vec::new();
while !data.is_empty() {
let message_bytes = match decoded_format {
XcmpMessageFormat::ConcatenatedVersionedXcm =>
Self::take_first_concatenated_xcm(data, &mut WeightMeter::new()),
XcmpMessageFormat::ConcatenatedOpaqueVersionedXcm =>
Self::take_first_concatenated_opaque_xcm(data),
XcmpMessageFormat::ConcatenatedVersionedXcm => {
Self::take_first_concatenated_xcm(data, &mut WeightMeter::new())
},
XcmpMessageFormat::ConcatenatedOpaqueVersionedXcm => {
Self::take_first_concatenated_opaque_xcm(data)
},
unexpected_format => {
panic!("Unexpected XCMP format: {unexpected_format:?}!")
},
@@ -279,9 +279,9 @@ pub mod v4 {
let pre_default = v2::QueueConfigData::default();
// If the previous values are the default ones, let's replace them with the new
// default.
if pre.suspend_threshold == pre_default.suspend_threshold &&
pre.drop_threshold == pre_default.drop_threshold &&
pre.resume_threshold == pre_default.resume_threshold
if pre.suspend_threshold == pre_default.suspend_threshold
&& pre.drop_threshold == pre_default.drop_threshold
&& pre.resume_threshold == pre_default.resume_threshold
{
return QueueConfigData::default();
}
+2 -2
View File
@@ -126,8 +126,8 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
kind: OriginKind,
) -> Result<RuntimeOrigin, Location> {
let origin = origin.into();
if kind == OriginKind::Superuser &&
matches!(
if kind == OriginKind::Superuser
&& matches!(
origin.unpack(),
(1, [Teyrchain(id)]) if ParaId::from(*id).is_system(),
) {
+3 -2
View File
@@ -353,11 +353,12 @@ impl CumulusDigestItem {
/// well-behaving runtimes should not produce headers with more than one.
pub fn extract_relay_parent(digest: &Digest) -> Option<relay_chain::Hash> {
digest.convert_first(|d| match d {
DigestItem::Consensus(id, val) if id == &CUMULUS_CONSENSUS_ID =>
DigestItem::Consensus(id, val) if id == &CUMULUS_CONSENSUS_ID => {
match CumulusDigestItem::decode(&mut &val[..]) {
Ok(CumulusDigestItem::RelayParent(hash)) => Some(hash),
_ => None,
},
}
},
_ => None,
})
}
+2 -2
View File
@@ -61,8 +61,8 @@ impl InherentDataProvider {
pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> {
// As the teyrchain starts building at around `relay_chain_slot + 1` we use that slot to
// calculate the timestamp.
let data: InherentType = ((*self.relay_chain_slot + 1) *
self.relay_chain_slot_duration.as_millis() as u64)
let data: InherentType = ((*self.relay_chain_slot + 1)
* self.relay_chain_slot_duration.as_millis() as u64)
.into();
inherent_data.put_data(INHERENT_IDENTIFIER, &data)
@@ -538,12 +538,14 @@ pub mod mock {
a: &Asset,
) -> core::result::Result<(AssetId, Balance), xcm_executor::traits::Error> {
match a {
Asset { fun: Fungible(amount), id: AssetId(inner_location) } =>
Asset { fun: Fungible(amount), id: AssetId(inner_location) } => {
match inner_location.unpack() {
(0, [Junction::GeneralIndex(id)]) =>
Ok(((*id).try_into().unwrap(), *amount)),
(0, [Junction::GeneralIndex(id)]) => {
Ok(((*id).try_into().unwrap(), *amount))
},
_ => Err(xcm_executor::traits::Error::AssetNotHandled),
},
}
},
_ => Err(xcm_executor::traits::Error::AssetNotHandled),
}
}
@@ -59,9 +59,10 @@ pub fn preset_names() -> Vec<PresetId> {
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
let patch = match id.as_ref() {
pezsp_genesis_builder::DEV_RUNTIME_PRESET |
pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET =>
testnet_genesis_with_default_endowed(100.into()),
pezsp_genesis_builder::DEV_RUNTIME_PRESET
| pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => {
testnet_genesis_with_default_endowed(100.into())
},
_ => return None,
};
Some(
+3 -2
View File
@@ -328,10 +328,11 @@ impl BizinikiwiCli for TestCollatorCli {
2500,
)))) as Box<_>
},
"relay-parent-offset" =>
"relay-parent-offset" => {
Box::new(pezcumulus_test_service::get_relay_parent_offset_chain_spec(Some(
ParaId::from(2600),
))) as Box<_>,
))) as Box<_>
},
path => {
let chain_spec: pezsc_chain_spec::GenericChainSpec =
pezsc_chain_spec::GenericChainSpec::from_json_file(path.into())?;
+9 -6
View File
@@ -273,7 +273,7 @@ async fn build_relay_chain_interface(
Some("Relaychain"),
)
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?,
pezcumulus_client_cli::RelayChainMode::ExternalRpc(rpc_target_urls) =>
pezcumulus_client_cli::RelayChainMode::ExternalRpc(rpc_target_urls) => {
return build_minimal_relay_chain_node_with_rpc(
relay_chain_config,
teyrchain_prometheus_registry,
@@ -281,7 +281,8 @@ async fn build_relay_chain_interface(
rpc_target_urls,
)
.await
.map(|r| r.0),
.map(|r| r.0)
},
};
task_manager.add_child(relay_chain_node.task_manager);
@@ -716,7 +717,7 @@ impl TestNodeBuilder {
let (task_manager, client, network, rpc_handlers, transaction_pool, backend) =
match relay_chain_config.network.network_backend {
pezsc_network::config::NetworkBackendType::Libp2p =>
pezsc_network::config::NetworkBackendType::Libp2p => {
start_node_impl::<_, pezsc_network::NetworkWorker<_, _>>(
teyrchain_config,
self.collator_key,
@@ -729,8 +730,9 @@ impl TestNodeBuilder {
false,
)
.await
.expect("could not create Pezcumulus test service"),
pezsc_network::config::NetworkBackendType::Litep2p =>
.expect("could not create Pezcumulus test service")
},
pezsc_network::config::NetworkBackendType::Litep2p => {
start_node_impl::<_, pezsc_network::Litep2pNetworkBackend>(
teyrchain_config,
self.collator_key,
@@ -743,7 +745,8 @@ impl TestNodeBuilder {
false,
)
.await
.expect("could not create Pezcumulus test service"),
.expect("could not create Pezcumulus test service")
},
};
let peer_id = network.local_peer_id();
let multiaddr = pezkuwi_test_service::get_listen_address(network.clone()).await;
+6 -4
View File
@@ -100,7 +100,7 @@ fn main() -> Result<(), pezsc_cli::Error> {
let (mut task_manager, _, _, _, _, _) = tokio_runtime
.block_on(async move {
match relay_chain_config.network.network_backend {
pezsc_network::config::NetworkBackendType::Libp2p =>
pezsc_network::config::NetworkBackendType::Libp2p => {
pezcumulus_test_service::start_node_impl::<
_,
pezsc_network::NetworkWorker<_, _>,
@@ -115,8 +115,9 @@ fn main() -> Result<(), pezsc_cli::Error> {
true,
use_slot_based_collator,
)
.await,
pezsc_network::config::NetworkBackendType::Litep2p =>
.await
},
pezsc_network::config::NetworkBackendType::Litep2p => {
pezcumulus_test_service::start_node_impl::<
_,
pezsc_network::Litep2pNetworkBackend,
@@ -131,7 +132,8 @@ fn main() -> Result<(), pezsc_cli::Error> {
true,
use_slot_based_collator,
)
.await,
.await
},
}
})
.expect("could not create Pezcumulus test service");
+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 { .. }
),
}
}

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