diff --git a/libs/types/src/tokens.rs b/libs/types/src/tokens.rs index c0741a00b7..b365bf72f0 100644 --- a/libs/types/src/tokens.rs +++ b/libs/types/src/tokens.rs @@ -14,7 +14,7 @@ use core::marker::PhantomData; use cfg_primitives::{ types::{PoolId, TrancheId}, - Balance, PalletIndex, + Balance, }; use cfg_traits::{investments::TrancheCurrency as TrancheCurrencyT, HasLocalAssetRepresentation}; use orml_traits::asset_registry; @@ -22,11 +22,6 @@ use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_runtime::{traits::Get, DispatchError, TokenError}; -use staging_xcm::{ - prelude::{AccountKey20, GlobalConsensus, PalletInstance}, - v3::{MultiLocation, NetworkId}, - VersionedMultiLocation, -}; use crate::{domain_address::DomainAddress, xcm::XcmMetadata, EVMChainId}; @@ -493,8 +488,6 @@ pub mod before { } pub mod usdc { - use sp_std::vec::Vec; - use super::*; pub const MIN_SWAP_ORDER_AMOUNT: Balance = 10_000_000; @@ -530,47 +523,6 @@ pub mod usdc { hex_literal::hex!("af88d065e77c8cC2239327C5EDb3A432268e5831"); pub const CONTRACT_CELO: [u8; 20] = hex_literal::hex!("37f750B7cC259A2f741AF45294f6a16572CF5cAd"); - - /// The metadata generator for the LP wrapped USDC currencies - // TODO(future): If no further LP wrapped USDC variants are expected, move this - // to `chain_spec.rs`. - pub fn lp_wrapped_usdc_metadata( - name: Vec, - symbol: Vec, - pallet_index: PalletIndex, - chain_id: EVMChainId, - contract_address_usdc: [u8; 20], - pool_currency: bool, - ) -> Result { - Ok(AssetMetadata { - decimals: DECIMALS, - name: name - .try_into() - .map_err(|_| DispatchError::Other("asset name exceeds limit"))?, - symbol: symbol - .try_into() - .map_err(|_| DispatchError::Other("asset symbol exceeds limit"))?, - existential_deposit: EXISTENTIAL_DEPOSIT, - location: Some(VersionedMultiLocation::V3(MultiLocation { - parents: 0, - interior: staging_xcm::v3::Junctions::X3( - PalletInstance(pallet_index), - GlobalConsensus(NetworkId::Ethereum { chain_id }), - AccountKey20 { - network: None, - key: contract_address_usdc, - }, - ), - })), - additional: CustomMetadata { - transferability: CrossChainTransferability::LiquidityPools, - mintable: false, - permissioned: false, - pool_currency, - local_representation: Some(LOCAL_ASSET_ID), - }, - }) - } } #[cfg(test)] diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index dd4fcac697..d1bc92fc35 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -31,13 +31,7 @@ use cfg_primitives::{ }; use cfg_types::{ fee_keys::FeeKey, - tokens::{ - usdc::{ - lp_wrapped_usdc_metadata, CHAIN_ID_ETH_GOERLI_TESTNET, CONTRACT_ETH_GOERLI, - CURRENCY_ID_LOCAL, CURRENCY_ID_LP_ETH_GOERLI, - }, - AssetMetadata, CrossChainTransferability, CurrencyId, CustomMetadata, - }, + tokens::{usdc, AssetMetadata, CrossChainTransferability, CurrencyId, CustomMetadata}, }; use cfg_utils::vec_to_fixed_array; use cumulus_primitives_core::ParaId; @@ -52,8 +46,10 @@ use sp_runtime::{ FixedPointNumber, }; use staging_xcm::{ - latest::MultiLocation, - prelude::{GeneralIndex, GeneralKey, PalletInstance, Parachain, X2, X3}, + latest::{MultiLocation, NetworkId}, + prelude::{ + AccountKey20, GeneralIndex, GeneralKey, GlobalConsensus, PalletInstance, Parachain, X2, X3, + }, }; /// Specialized `ChainSpec` instances for our runtimes. @@ -1053,7 +1049,7 @@ fn asset_registry_assets() -> Vec<(CurrencyId, Vec)> { .encode(), ), ( - CURRENCY_ID_LOCAL, + usdc::CURRENCY_ID_LOCAL, AssetMetadata { decimals: 6, name: b"Local USDC" @@ -1077,21 +1073,39 @@ fn asset_registry_assets() -> Vec<(CurrencyId, Vec)> { .encode(), ), ( - CURRENCY_ID_LP_ETH_GOERLI, - lp_wrapped_usdc_metadata( - b"LP Ethereum Wrapped USDC" + usdc::CURRENCY_ID_LP_ETH_GOERLI, + AssetMetadata { + decimals: usdc::DECIMALS, + name: b"LP Ethereum Wrapped USDC" .to_vec() .try_into() .expect("fit in the BoundedVec"), - b"LpEthUSDC" + symbol: b"LpEthUSDC" .to_vec() .try_into() .expect("fit in the BoundedVec"), - development_runtime::LiquidityPoolsPalletIndex::get(), - CHAIN_ID_ETH_GOERLI_TESTNET, - CONTRACT_ETH_GOERLI, - true, - ) + existential_deposit: usdc::EXISTENTIAL_DEPOSIT, + location: Some(staging_xcm::VersionedMultiLocation::V3(MultiLocation { + parents: 0, + interior: staging_xcm::v3::Junctions::X3( + PalletInstance(development_runtime::LiquidityPoolsPalletIndex::get()), + GlobalConsensus(NetworkId::Ethereum { + chain_id: usdc::CHAIN_ID_ETH_GOERLI_TESTNET, + }), + AccountKey20 { + network: None, + key: usdc::CONTRACT_ETH_GOERLI, + }, + ), + })), + additional: CustomMetadata { + transferability: CrossChainTransferability::LiquidityPools, + mintable: false, + permissioned: false, + pool_currency: true, + local_representation: Some(usdc::LOCAL_ASSET_ID), + }, + } .encode(), ), ] diff --git a/pallets/oracle-collection/src/lib.rs b/pallets/oracle-collection/src/lib.rs index 07b5e03626..d8c663ff6c 100644 --- a/pallets/oracle-collection/src/lib.rs +++ b/pallets/oracle-collection/src/lib.rs @@ -612,7 +612,7 @@ pub mod util { /// Computes fastly the median of a list of values /// Extracted from orml - pub fn median(items: &mut Vec) -> Option<&T> { + pub fn median(items: &mut [T]) -> Option<&T> { if items.is_empty() { return None; } diff --git a/pallets/pool-system/src/impls.rs b/pallets/pool-system/src/impls.rs index 30bb8dc146..1788bc3dad 100644 --- a/pallets/pool-system/src/impls.rs +++ b/pallets/pool-system/src/impls.rs @@ -137,7 +137,7 @@ impl PoolMutate for Pallet { tranche_type: t.tranche_type, seniority: t.seniority, }) - .collect(), + .collect::>(), )?; Self::take_deposit(depositor.clone(), pool_id)?; diff --git a/pallets/pool-system/src/lib.rs b/pallets/pool-system/src/lib.rs index f39f5db24b..a471a4048e 100644 --- a/pallets/pool-system/src/lib.rs +++ b/pallets/pool-system/src/lib.rs @@ -1147,7 +1147,7 @@ pub mod pallet { pub fn is_valid_tranche_change( old_tranches: Option<&TranchesOf>, - new_tranches: &Vec>, + new_tranches: &[TrancheUpdate], ) -> DispatchResult { // There is a limit to the number of allowed tranches ensure!( diff --git a/pallets/pool-system/src/pool_types.rs b/pallets/pool-system/src/pool_types.rs index 7a316e2c11..f5b800461d 100644 --- a/pallets/pool-system/src/pool_types.rs +++ b/pallets/pool-system/src/pool_types.rs @@ -273,18 +273,16 @@ impl< let mut tranches: Vec> = Vec::new(); for tranche in self.tranches.residual_top_slice().iter() { - let metadata = AssetRegistry::metadata(&self.currency.into()).ok_or( - DispatchError::Other("Always exists a currency for an existing pool"), - )?; + let metadata = AssetRegistry::metadata(&self.currency).ok_or(DispatchError::Other( + "Always exists a currency for an existing pool", + ))?; tranches.push(TrancheEssence { currency: tranche.currency, ty: tranche.tranche_type, metadata: TrancheMetadata { - token_name: BoundedVec::try_from(metadata.name) - .unwrap_or(BoundedVec::default()), - token_symbol: BoundedVec::try_from(metadata.symbol) - .unwrap_or(BoundedVec::default()), + token_name: metadata.name, + token_symbol: metadata.symbol, }, }); } diff --git a/runtime/common/src/oracle.rs b/runtime/common/src/oracle.rs index 8ecc509c92..931bae13d2 100644 --- a/runtime/common/src/oracle.rs +++ b/runtime/common/src/oracle.rs @@ -34,6 +34,9 @@ impl> Feeder { } } +// There is an issue with clippy that detect this as an error: +// https://github.com/rust-lang/rust-clippy/issues/12245 +#[allow(clippy::unconditional_recursion)] impl PartialEq for Feeder { fn eq(&self, other: &Self) -> bool { self.0.eq(&other.0)