Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Jan 16, 2025
1 parent ad6d1f4 commit f58c376
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 59 deletions.
5 changes: 1 addition & 4 deletions nodes/parachain/src/chain_spec/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use polimec_runtime::{
AccountId, AuraId as AuthorityId, Balance, BlockchainOperationTreasury, ContributionTreasuryAccount,
ExistentialDeposit, FeeRecipient, OracleProvidersMembershipConfig, Runtime, TreasuryAccount, PLMC,
};
use sp_core::{
crypto::{Ss58AddressFormat, UncheckedInto},
sr25519,
};
use sp_core::{crypto::UncheckedInto, sr25519};
use sp_runtime::{traits::AccountIdConversion, Perbill, Percent};
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;

Expand Down
18 changes: 5 additions & 13 deletions pallets/funding/src/functions/1_application.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(clippy::wildcard_imports)]
#![allow(clippy::type_complexity)]

use sp_runtime::offchain::http::Method::Post;
use super::*;

impl<T: Config> Pallet<T> {
Expand Down Expand Up @@ -92,10 +91,7 @@ impl<T: Config> Pallet<T> {
// * Emit events *
Self::deposit_event(Event::ProjectCreated { project_id, issuer: issuer.clone(), metadata: project_metadata });

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
})
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[transactional]
Expand Down Expand Up @@ -123,10 +119,8 @@ impl<T: Config> Pallet<T> {
// * Emit events *
Self::deposit_event(Event::MetadataEdited { project_id, metadata: new_project_metadata });

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
}) }
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[transactional]
pub fn do_remove_project(issuer: AccountIdOf<T>, project_id: ProjectId, did: Did) -> DispatchResultWithPostInfo {
Expand All @@ -146,8 +140,6 @@ impl<T: Config> Pallet<T> {
// * Emit events *
Self::deposit_event(Event::ProjectRemoved { project_id, issuer });

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
}) }
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}
}
5 changes: 1 addition & 4 deletions pallets/funding/src/functions/2_evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ impl<T: Config> Pallet<T> {
false,
)?;

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
})
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[transactional]
Expand Down
23 changes: 10 additions & 13 deletions pallets/funding/src/functions/7_ct_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ impl<T: Config> Pallet<T> {
false,
)?;

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
}) }
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

#[transactional]
pub fn do_confirm_offchain_migration(
Expand Down Expand Up @@ -85,10 +83,8 @@ impl<T: Config> Pallet<T> {
false,
)?;

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
}) }
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

/// Handle the channel open request from the relay on behalf of a parachain.
/// If the parachain id belongs to a funded project with the same project id, then send an acceptance message and a request for a
Expand Down Expand Up @@ -210,7 +206,10 @@ impl<T: Config> Pallet<T> {
/// After the bidirectional HRMP channels are established, check that the project chain has the Polimec receiver pallet,
/// and has minted the amount of CTs sold to the Polimec sovereign account.
#[transactional]
pub fn do_start_pallet_migration_readiness_check(caller: &AccountIdOf<T>, project_id: ProjectId) -> DispatchResultWithPostInfo {
pub fn do_start_pallet_migration_readiness_check(
caller: &AccountIdOf<T>,
project_id: ProjectId,
) -> DispatchResultWithPostInfo {
// * Get variables *
let mut project_details = ProjectsDetails::<T>::get(project_id).ok_or(Error::<T>::ProjectDetailsNotFound)?;
let Some(MigrationType::Pallet(ref mut migration_info)) = project_details.migration_type else {
Expand Down Expand Up @@ -302,10 +301,8 @@ impl<T: Config> Pallet<T> {
// * Emit events *
Self::deposit_event(Event::<T>::MigrationReadinessCheckStarted { project_id, caller: caller.clone() });

Ok(PostDispatchInfo{
actual_weight: None,
pays_fee: Pays::No,
}) }
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::No })
}

/// Handle the migration readiness check response from the project chain.
#[transactional]
Expand Down
1 change: 0 additions & 1 deletion pallets/funding/src/functions/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ impl<T: Config> Pallet<T> {
frame_system::Pallet::<T>::account_nonce(polimec_account),
);


let ecdsa_signature = EcdsaSignature::from_slice(&signature_bytes).unwrap();
let public_compressed: EcdsaPublic = ecdsa_signature.recover_prehashed(&hashed_message).unwrap();
let public_uncompressed = k256::ecdsa::VerifyingKey::from_sec1_bytes(&public_compressed).unwrap();
Expand Down
22 changes: 15 additions & 7 deletions pallets/funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ pub mod pallet {
origin: OriginFor<T>,
jwt: UntrustedToken,
project: ProjectMetadataOf<T>,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let (account, did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand All @@ -715,7 +715,11 @@ pub mod pallet {

#[pallet::call_index(1)]
#[pallet::weight(WeightInfoOf::<T>::remove_project())]
pub fn remove_project(origin: OriginFor<T>, jwt: UntrustedToken, project_id: ProjectId) -> DispatchResult {
pub fn remove_project(
origin: OriginFor<T>,
jwt: UntrustedToken,
project_id: ProjectId,
) -> DispatchResultWithPostInfo {
let (account, did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand All @@ -730,7 +734,7 @@ pub mod pallet {
jwt: UntrustedToken,
project_id: ProjectId,
new_project_metadata: ProjectMetadataOf<T>,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let (account, _did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand All @@ -740,7 +744,11 @@ pub mod pallet {
/// Starts the evaluation round of a project. It needs to be called by the project issuer.
#[pallet::call_index(3)]
#[pallet::weight(WeightInfoOf::<T>::start_evaluation())]
pub fn start_evaluation(origin: OriginFor<T>, jwt: UntrustedToken, project_id: ProjectId) -> DispatchResult {
pub fn start_evaluation(
origin: OriginFor<T>,
jwt: UntrustedToken,
project_id: ProjectId,
) -> DispatchResultWithPostInfo {
let (account, _did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand Down Expand Up @@ -1024,7 +1032,7 @@ pub mod pallet {
origin: OriginFor<T>,
jwt: UntrustedToken,
project_id: ProjectId,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let (account, _did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand All @@ -1051,7 +1059,7 @@ pub mod pallet {
jwt: UntrustedToken,
project_id: ProjectId,
para_id: ParaId,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let (account, _did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand All @@ -1065,7 +1073,7 @@ pub mod pallet {
origin: OriginFor<T>,
jwt: UntrustedToken,
project_id: ProjectId,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
let (account, _did, investor_type, _cid) =
T::InvestorOrigin::ensure_origin(origin, &jwt, T::VerifierPublicKey::get())?;
ensure!(investor_type == InvestorType::Institutional, Error::<T>::WrongInvestorType);
Expand Down
1 change: 0 additions & 1 deletion pallets/funding/src/runtime_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::traits::BondingRequirementCalculation;
#[allow(clippy::wildcard_imports)]
use crate::{traits::BondingRequirementCalculation, *};
use alloc::{collections::BTreeMap, string::String};
Expand Down
2 changes: 1 addition & 1 deletion pallets/oracle-ocw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub mod pallet {
None
}
})
.collect::<Vec<AssetName>>();
.collect::<Vec<AssetName>>();

if assets.is_empty() {
log::trace!(target: LOG_TARGET, "Assets to fetch list is empty :c");
Expand Down
24 changes: 12 additions & 12 deletions runtimes/polimec/src/custom_migrations/asset_id_migration.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use crate::{AccountId, Funding, Oracle, Runtime};
use alloc::{collections::BTreeMap, vec::Vec};
use crate::{AccountId, Funding, Runtime};
use alloc::collections::BTreeMap;
use frame_support::{
migrations::VersionedPostUpgradeData,
pallet_prelude::{NMapKey, StorageDoubleMap, StorageMap, StorageNMap, StorageValue, ValueQuery},
pallet_prelude::{NMapKey, ValueQuery},
storage_alias,
traits::{GetStorageVersion, OnRuntimeUpgrade},
Blake2_128Concat,
};
use itertools::Itertools;
use pallet_assets::{Approval, AssetAccount, AssetDetails, AssetMetadata};
use parity_scale_codec::Encode;
use polimec_common::assets::AcceptedFundingAsset;
use sp_api::runtime_decl_for_core::CoreV5;
use sp_runtime::BoundedVec;
Expand Down Expand Up @@ -87,20 +85,18 @@ pub mod orml_oracle_storage_items {
use super::*;

pub mod old_types {
use super::*;
use frame_support::Twox64Concat;
use orml_oracle::TimestampedValue;
use shared_configuration::Price;
use super::*;

type TimeStampedValueOf = TimestampedValue<Price, u64>;

#[storage_alias]
pub type RawValues =
StorageDoubleMap<Oracle, Twox64Concat, AccountId, Twox64Concat, u32, TimeStampedValueOf>;
pub type RawValues = StorageDoubleMap<Oracle, Twox64Concat, AccountId, Twox64Concat, u32, TimeStampedValueOf>;

#[storage_alias]
pub type Values =
StorageMap<Oracle, Twox64Concat, u32, TimeStampedValueOf>;
pub type Values = StorageMap<Oracle, Twox64Concat, u32, TimeStampedValueOf>;
}
}

Expand Down Expand Up @@ -131,7 +127,7 @@ impl OnRuntimeUpgrade for FromOldAssetIdMigration {
(1984, AcceptedFundingAsset::USDT.id()),
(1337, AcceptedFundingAsset::USDC.id()),
(10, AcceptedFundingAsset::DOT.id()),
(3344, Location::here())
(3344, Location::here()),
]);

let old_account_iterator = pallet_assets_storage_items::old_types::Account::iter().collect_vec();
Expand Down Expand Up @@ -177,7 +173,11 @@ impl OnRuntimeUpgrade for FromOldAssetIdMigration {
for (account, old_asset_id, raw_values) in old_oracle_raw_values_iterator {
items += 1;
log::info!("old_oracle_raw_values item {:?}", items);
orml_oracle::RawValues::<Runtime>::insert(account.clone(), id_map.get(&old_asset_id).unwrap(), raw_values);
orml_oracle::RawValues::<Runtime>::insert(
account.clone(),
id_map.get(&old_asset_id).unwrap(),
raw_values,
);
orml_oracle_storage_items::old_types::RawValues::remove(account, old_asset_id);
}

Expand Down
9 changes: 6 additions & 3 deletions runtimes/polimec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use sp_std::{cmp::Ordering, prelude::*};
use sp_version::RuntimeVersion;

// XCM Imports
use xcm::{v3::MultiLocation, VersionedAssets, VersionedLocation, VersionedXcm};
use xcm::{VersionedAssets, VersionedLocation, VersionedXcm};
use xcm_config::{PriceForSiblingParachainDelivery, XcmOriginToTransactDispatchOrigin};
use xcm_fee_payment_runtime_api::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
Expand All @@ -98,7 +98,10 @@ use alloc::string::String;
use sp_core::crypto::Ss58Codec;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use xcm::{v4::Location, VersionedAssetId};
use xcm::{
v4::{Junction::Parachain, Location, Parent, ParentThen},
VersionedAssetId,
};

#[cfg(feature = "runtime-benchmarks")]
mod benchmark_helpers;
Expand Down Expand Up @@ -443,7 +446,7 @@ pub struct PalletAssetsBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pallet_assets::BenchmarkHelper<Location> for PalletAssetsBenchmarkHelper {
fn create_asset_id_parameter(id: u32) -> Location {
(Parent, Parachain(id)).into()
Location::from(ParentThen([Parachain(id)].into()))
}
}
impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
Expand Down

0 comments on commit f58c376

Please sign in to comment.