diff --git a/pallets/slp/src/agents/filecoin_agent/agent.rs b/pallets/slp/src/agents/filecoin_agent/agent.rs index c3c9b3ff6..22c90e1e6 100644 --- a/pallets/slp/src/agents/filecoin_agent/agent.rs +++ b/pallets/slp/src/agents/filecoin_agent/agent.rs @@ -20,8 +20,8 @@ use crate::{ primitives::{FilecoinLedger, Ledger}, traits::StakingAgent, AccountIdOf, BalanceOf, BoundedVec, Config, DelegatorLatestTuneRecord, DelegatorLedgers, - LedgerUpdateEntry, MinimumsAndMaximums, Pallet, TimeUnit, Validators, ValidatorsByDelegator, - ValidatorsByDelegatorUpdateEntry, + HostingFees, LedgerUpdateEntry, MinimumsAndMaximums, Pallet, TimeUnit, Validators, + ValidatorsByDelegator, ValidatorsByDelegatorUpdateEntry, }; use bifrost_primitives::{CurrencyId, VtokenMintingOperator}; use core::marker::PhantomData; @@ -447,7 +447,7 @@ impl // issue the increased interest amount to the entrance account // Get charged fee value let (fee_permill, _beneficiary) = - Pallet::::get_hosting_fee(currency_id).ok_or(Error::::InvalidHostingFee)?; + HostingFees::::get(currency_id).ok_or(Error::::InvalidHostingFee)?; let fee_to_charge = fee_permill.mul_floor(token_amount); let amount_to_increase = token_amount.checked_sub(&fee_to_charge).ok_or(Error::::UnderFlow)?; diff --git a/pallets/slp/src/agents/utils.rs b/pallets/slp/src/agents/utils.rs index 228d362f4..c2cb60474 100644 --- a/pallets/slp/src/agents/utils.rs +++ b/pallets/slp/src/agents/utils.rs @@ -16,8 +16,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . use crate::{ - blake2_256, pallet::Error, AccountIdOf, Config, Decode, LedgerUpdateEntry, MinimumsAndMaximums, - Pallet, TrailingZeroInput, Validators, ValidatorsByDelegatorUpdateEntry, ASTR, DOT, GLMR, H160, + blake2_256, pallet::Error, AccountIdOf, Config, Decode, DelegatorLedgerXcmUpdateQueue, + LedgerUpdateEntry, MinimumsAndMaximums, Pallet, TrailingZeroInput, Validators, + ValidatorsByDelegatorUpdateEntry, ValidatorsByDelegatorXcmUpdateQueue, ASTR, DOT, GLMR, H160, KSM, MANTA, MOVR, PHA, }; use bifrost_primitives::CurrencyId; @@ -211,7 +212,7 @@ impl Pallet { // See if the query exists. If it exists, call corresponding chain storage update // function. let (entry, timeout) = - Self::get_delegator_ledger_update_entry(query_id).ok_or(Error::::QueryNotExist)?; + DelegatorLedgerXcmUpdateQueue::::get(query_id).ok_or(Error::::QueryNotExist)?; let now = frame_system::Pallet::::block_number(); let mut updated = true; @@ -244,7 +245,7 @@ impl Pallet { ) -> Result> { // See if the query exists. If it exists, call corresponding chain storage update // function. - let (entry, timeout) = Self::get_validators_by_delegator_update_entry(query_id) + let (entry, timeout) = ValidatorsByDelegatorXcmUpdateQueue::::get(query_id) .ok_or(Error::::QueryNotExist)?; let now = frame_system::Pallet::::block_number(); @@ -274,7 +275,7 @@ impl Pallet { // See if the query exists. If it exists, call corresponding chain storage update // function. let (entry, _) = - Self::get_delegator_ledger_update_entry(query_id).ok_or(Error::::QueryNotExist)?; + DelegatorLedgerXcmUpdateQueue::::get(query_id).ok_or(Error::::QueryNotExist)?; let currency_id = match entry { LedgerUpdateEntry::Substrate(substrate_entry) => Some(substrate_entry.currency_id), LedgerUpdateEntry::ParachainStaking(moonbeam_entry) => Some(moonbeam_entry.currency_id), @@ -293,7 +294,7 @@ impl Pallet { ) -> Result<(), Error> { // See if the query exists. If it exists, call corresponding chain storage update // function. - let (entry, _) = Self::get_validators_by_delegator_update_entry(query_id) + let (entry, _) = ValidatorsByDelegatorXcmUpdateQueue::::get(query_id) .ok_or(Error::::QueryNotExist)?; let currency_id = match entry { ValidatorsByDelegatorUpdateEntry::Substrate(substrate_entry) => diff --git a/pallets/slp/src/lib.rs b/pallets/slp/src/lib.rs index 260ee7850..d4a5fd67a 100644 --- a/pallets/slp/src/lib.rs +++ b/pallets/slp/src/lib.rs @@ -537,25 +537,21 @@ pub mod pallet { /// One operate origin(can be a multisig account) for a currency. An operating origins are /// normal account in Bifrost chain. #[pallet::storage] - #[pallet::getter(fn get_operate_origin)] pub type OperateOrigins = StorageMap<_, Blake2_128Concat, CurrencyId, AccountIdOf>; /// Origins and Amounts for the staking operating account fee supplement. An operating account /// is identified in MultiLocation format. #[pallet::storage] - #[pallet::getter(fn get_fee_source)] pub type FeeSources = StorageMap<_, Blake2_128Concat, CurrencyId, (MultiLocation, BalanceOf)>; /// Hosting fee percentage and beneficiary account for different chains #[pallet::storage] - #[pallet::getter(fn get_hosting_fee)] pub type HostingFees = StorageMap<_, Blake2_128Concat, CurrencyId, (Permill, MultiLocation)>; /// Delegators in service. A delegator is identified in MultiLocation format. /// Currency Id + Sub-account index => MultiLocation #[pallet::storage] - #[pallet::getter(fn get_delegator_multilocation_by_index)] pub type DelegatorsIndex2Multilocation = StorageDoubleMap< _, Blake2_128Concat, @@ -568,7 +564,6 @@ pub mod pallet { /// Delegators in service. Currency Id + MultiLocation => Sub-account index #[pallet::storage] - #[pallet::getter(fn get_delegator_index_by_multilocation)] pub type DelegatorsMultilocation2Index = StorageDoubleMap< _, Blake2_128Concat, @@ -581,18 +576,15 @@ pub mod pallet { /// Next index of different currency delegators. #[pallet::storage] - #[pallet::getter(fn get_delegator_next_index)] pub type DelegatorNextIndex = StorageMap<_, Blake2_128Concat, CurrencyId, u16, ValueQuery>; /// (VWL) Validator in service. A validator is identified in MultiLocation format. #[pallet::storage] - #[pallet::getter(fn get_validators)] pub type Validators = StorageMap<_, Blake2_128Concat, CurrencyId, BoundedVec>; /// (VBL) Validator Boost List -> (validator multilocation, due block number) #[pallet::storage] - #[pallet::getter(fn get_validator_boost_list)] pub type ValidatorBoostList = StorageMap< _, Blake2_128Concat, @@ -602,7 +594,6 @@ pub mod pallet { /// Validators for each delegator. CurrencyId + Delegator => Vec #[pallet::storage] - #[pallet::getter(fn get_validators_by_delegator)] pub type ValidatorsByDelegator = StorageDoubleMap< _, Blake2_128Concat, @@ -614,7 +605,6 @@ pub mod pallet { >; #[pallet::storage] - #[pallet::getter(fn get_validators_by_delegator_update_entry)] pub type ValidatorsByDelegatorXcmUpdateQueue = StorageMap< _, Blake2_128Concat, @@ -624,7 +614,6 @@ pub mod pallet { /// Delegator ledgers. A delegator is identified in MultiLocation format. #[pallet::storage] - #[pallet::getter(fn get_delegator_ledger)] pub type DelegatorLedgers = StorageDoubleMap< _, Blake2_128Concat, @@ -636,7 +625,6 @@ pub mod pallet { >; #[pallet::storage] - #[pallet::getter(fn get_delegator_ledger_update_entry)] pub type DelegatorLedgerXcmUpdateQueue = StorageMap< _, Blake2_128Concat, @@ -646,19 +634,16 @@ pub mod pallet { /// Minimum and Maximum constraints for different chains. #[pallet::storage] - #[pallet::getter(fn get_minimums_maximums)] pub type MinimumsAndMaximums = StorageMap<_, Blake2_128Concat, CurrencyId, MinimumsMaximums>>; /// TimeUnit delay params for different chains. #[pallet::storage] - #[pallet::getter(fn get_currency_delays)] pub type CurrencyDelays = StorageMap<_, Blake2_128Concat, CurrencyId, Delays>; /// A delegator's tuning record of exchange rate for the current time unit. /// Currency Id + Delegator Id => latest tuned TimeUnit #[pallet::storage] - #[pallet::getter(fn get_delegator_latest_tune_record)] pub type DelegatorLatestTuneRecord = StorageDoubleMap< _, Blake2_128Concat, @@ -672,7 +657,6 @@ pub mod pallet { /// Currency's tuning record of exchange rate for the current time unit. /// Currency Id => (latest tuned TimeUnit, number of tuning times) #[pallet::storage] - #[pallet::getter(fn get_currency_latest_tune_record)] pub type CurrencyLatestTuneRecord = StorageMap<_, Blake2_128Concat, CurrencyId, (TimeUnit, u32), OptionQuery>; @@ -680,28 +664,23 @@ pub mod pallet { /// rate for a single time unit, and how much at most each time can tune the /// exchange rate #[pallet::storage] - #[pallet::getter(fn get_currency_tune_exchange_rate_limit)] pub type CurrencyTuneExchangeRateLimit = StorageMap<_, Blake2_128Concat, CurrencyId, (u32, Permill)>; /// reflect if all delegations are on a decrease/revoke status. If yes, then new user redeeming /// is unaccepted. #[pallet::storage] - #[pallet::getter(fn get_all_delegations_occupied_status)] pub type DelegationsOccupied = StorageMap<_, Blake2_128Concat, CurrencyId, bool>; #[pallet::storage] - #[pallet::getter(fn get_last_time_updated_ongoing_time_unit)] pub type LastTimeUpdatedOngoingTimeUnit = StorageMap<_, Blake2_128Concat, CurrencyId, BlockNumberFor>; #[pallet::storage] - #[pallet::getter(fn get_ongoing_time_unit_update_interval)] pub type OngoingTimeUnitUpdateInterval = StorageMap<_, Blake2_128Concat, CurrencyId, BlockNumberFor>; #[pallet::storage] - #[pallet::getter(fn get_supplement_fee_account_wihtelist)] pub type SupplementFeeAccountWhitelist = StorageMap<_, Blake2_128Concat, CurrencyId, Vec<(MultiLocation, Hash)>>; @@ -1271,7 +1250,7 @@ pub mod pallet { ensure!(value > Zero::zero(), Error::::AmountZero); // Ensure the value is valid. - let (limit_num, max_permill) = Self::get_currency_tune_exchange_rate_limit(currency_id) + let (limit_num, max_permill) = CurrencyTuneExchangeRateLimit::::get(currency_id) .ok_or(Error::::TuneExchangeRateLimitNotSet)?; // Get pool token value let pool_token = T::VtokenMinting::get_token_pool(currency_id); @@ -1290,9 +1269,8 @@ pub mod pallet { } // Get CurrencyLatestTuneRecord for the currencyId. - let (latest_time_unit, tune_num) = - Self::get_currency_latest_tune_record(currency_id) - .ok_or(Error::::CurrencyLatestTuneRecordNotExist)?; + let (latest_time_unit, tune_num) = CurrencyLatestTuneRecord::::get(currency_id) + .ok_or(Error::::CurrencyLatestTuneRecordNotExist)?; // See if exceeds tuning limit. // If it has been tuned in the current time unit, ensure this tuning is within limit. @@ -1306,7 +1284,7 @@ pub mod pallet { // Get charged fee value let (fee_permill, beneficiary) = - Self::get_hosting_fee(currency_id).ok_or(Error::::InvalidHostingFee)?; + HostingFees::::get(currency_id).ok_or(Error::::InvalidHostingFee)?; let fee_to_charge = fee_permill.mul_floor(value); // Should first charge fee, and then tune exchange rate. Otherwise, the rate will be @@ -1940,7 +1918,7 @@ pub mod pallet { // Add the boost list to the validator set let mut validator_vec; - if let Some(validator_set) = Self::get_validators(currency_id) { + if let Some(validator_set) = Validators::::get(currency_id) { validator_vec = validator_set.to_vec(); } else { validator_vec = vec![]; @@ -2036,7 +2014,7 @@ pub mod pallet { due_block_number, }); - let validator_set_op = Self::get_validators(currency_id); + let validator_set_op = Validators::::get(currency_id); let mut validator_vec; // Add the newly added validator to the validator set @@ -2282,14 +2260,14 @@ impl>> token: CurrencyIdOf, derivative_index: DerivativeIndex, ) -> bool { - Pallet::::get_delegator_multilocation_by_index(token, derivative_index).is_some() + DelegatorsIndex2Multilocation::::get(token, derivative_index).is_some() } fn get_multilocation( token: CurrencyIdOf, derivative_index: DerivativeIndex, ) -> Option { - Pallet::::get_delegator_multilocation_by_index(token, derivative_index) + DelegatorsIndex2Multilocation::::get(token, derivative_index) } fn get_stake_info( @@ -2297,7 +2275,7 @@ impl>> derivative_index: DerivativeIndex, ) -> Option<(BalanceOf, BalanceOf)> { Self::get_multilocation(token, derivative_index).and_then(|location| { - Pallet::::get_delegator_ledger(token, location).and_then(|ledger| match ledger { + DelegatorLedgers::::get(token, location).and_then(|ledger| match ledger { Ledger::Substrate(l) if F::contains(&token) => Some((l.total, l.active)), _ => None, }) diff --git a/pallets/slp/src/tests/kusama_tests.rs b/pallets/slp/src/tests/kusama_tests.rs index 20731999f..003a0e1cf 100644 --- a/pallets/slp/src/tests/kusama_tests.rs +++ b/pallets/slp/src/tests/kusama_tests.rs @@ -279,7 +279,8 @@ fn set_hosting_fees_works() { Some((pct, treasury_location)) )); - let (fee, location) = Slp::get_hosting_fee(KSM).unwrap(); + // let (fee, location) = Slp::get_hosting_fee(KSM).unwrap(); + let (fee, location) = HostingFees::::get(KSM).unwrap(); assert_eq!(fee, pct); assert_eq!(location, treasury_location); }); diff --git a/pallets/slp/src/tests/manta_tests.rs b/pallets/slp/src/tests/manta_tests.rs index 3e3d1fd1c..a149bbd16 100644 --- a/pallets/slp/src/tests/manta_tests.rs +++ b/pallets/slp/src/tests/manta_tests.rs @@ -1619,7 +1619,7 @@ fn add_validator_and_remove_validator_works() { let bounded_valis = BoundedVec::try_from(valis).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_valis)); + assert_eq!(Validators::::get(MANTA), Some(bounded_valis)); assert_ok!(Slp::remove_validator( RuntimeOrigin::signed(ALICE), @@ -1628,7 +1628,7 @@ fn add_validator_and_remove_validator_works() { )); let empty_bounded_vec = BoundedVec::default(); - assert_eq!(Slp::get_validators(MANTA), Some(empty_bounded_vec)); + assert_eq!(Validators::::get(MANTA), Some(empty_bounded_vec)); }); } @@ -1655,7 +1655,7 @@ fn reset_validators_should_work() { validator_list_input )); - assert_eq!(Slp::get_validators(MANTA), Some(validator_list_output)); + assert_eq!(Validators::::get(MANTA), Some(validator_list_output)); }); } @@ -1695,9 +1695,12 @@ fn set_validator_boost_list_should_work() { let bounded_validator_list_output_1 = BoundedVec::try_from(validator_list_output_1).unwrap(); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(bounded_validator_list_output_1)); + assert_eq!( + ValidatorBoostList::::get(MANTA), + Some(bounded_validator_list_output_1) + ); let bounded_validator_0 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0)); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0)); System::set_block_number(400); @@ -1709,10 +1712,13 @@ fn set_validator_boost_list_should_work() { let bounded_validator_list_output_2 = BoundedVec::try_from(validator_list_output_2).unwrap(); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(bounded_validator_list_output_2)); + assert_eq!( + ValidatorBoostList::::get(MANTA), + Some(bounded_validator_list_output_2) + ); let bounded_validator_0_1 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION, VALIDATOR_1_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0_1),); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0_1),); }); } @@ -1740,10 +1746,10 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_1)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_1)); let bounded_validator_0 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0.clone())); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0.clone())); System::set_block_number(400); @@ -1753,9 +1759,9 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0)); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0)); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_2)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_2)); assert_ok!(Slp::add_to_validator_boost_list( RuntimeOrigin::signed(ALICE), @@ -1763,10 +1769,10 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_1_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_3)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_3)); let bounded_validator_0_1 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION, VALIDATOR_1_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0_1),); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0_1),); }); } @@ -1784,7 +1790,7 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output.clone())); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output.clone())); assert_ok!(Slp::remove_from_validator_boot_list( RuntimeOrigin::signed(ALICE), @@ -1792,7 +1798,7 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_1_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output)); assert_ok!(Slp::remove_from_validator_boot_list( RuntimeOrigin::signed(ALICE), @@ -1800,7 +1806,7 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), None); + assert_eq!(ValidatorBoostList::::get(MANTA), None); }); } @@ -1834,10 +1840,10 @@ fn clean_outdated_validator_boost_list_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_1)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_1)); let bounded_validator_0 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0.clone())); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0.clone())); System::set_block_number(400); @@ -1847,9 +1853,12 @@ fn clean_outdated_validator_boost_list_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0)); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0)); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_2.clone())); + assert_eq!( + ValidatorBoostList::::get(MANTA), + Some(validator_list_output_2.clone()) + ); assert_ok!(Slp::add_to_validator_boost_list( RuntimeOrigin::signed(ALICE), @@ -1857,10 +1866,13 @@ fn clean_outdated_validator_boost_list_work() { Box::new(VALIDATOR_1_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_3.clone())); + assert_eq!( + ValidatorBoostList::::get(MANTA), + Some(validator_list_output_3.clone()) + ); let bounded_validator_0_1 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION, VALIDATOR_1_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MANTA), Some(bounded_validator_0_1),); + assert_eq!(Validators::::get(MANTA), Some(bounded_validator_0_1),); // no validator due yet. Everything should be kept after calling // clean_outdated_validator_boost_list @@ -1871,7 +1883,7 @@ fn clean_outdated_validator_boost_list_work() { MANTA, 1 )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_3)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_3)); // move to block SIX_MONTHS + 400, validator 1 should be removable System::set_block_number(400 + SIX_MONTHS as u64); @@ -1888,7 +1900,10 @@ fn clean_outdated_validator_boost_list_work() { MANTA, 1 )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_2.clone())); + assert_eq!( + ValidatorBoostList::::get(MANTA), + Some(validator_list_output_2.clone()) + ); // do it again assert_ok!(Slp::clean_outdated_validator_boost_list( @@ -1896,7 +1911,7 @@ fn clean_outdated_validator_boost_list_work() { MANTA, 1 )); - assert_eq!(Slp::get_validator_boost_list(MANTA), Some(validator_list_output_2)); + assert_eq!(ValidatorBoostList::::get(MANTA), Some(validator_list_output_2)); assert_noop!( Slp::clean_outdated_validator_boost_list(RuntimeOrigin::signed(ALICE), MANTA, 2), diff --git a/pallets/slp/src/tests/moonriver_tests.rs b/pallets/slp/src/tests/moonriver_tests.rs index 64f523732..34d7f1839 100644 --- a/pallets/slp/src/tests/moonriver_tests.rs +++ b/pallets/slp/src/tests/moonriver_tests.rs @@ -1641,7 +1641,7 @@ fn add_validator_and_remove_validator_works() { let bounded_valis = BoundedVec::try_from(valis).unwrap(); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_valis)); + assert_eq!(Validators::::get(MOVR), Some(bounded_valis)); assert_ok!(Slp::remove_validator( RuntimeOrigin::signed(ALICE), @@ -1650,7 +1650,7 @@ fn add_validator_and_remove_validator_works() { )); let empty_bounded_vec = BoundedVec::default(); - assert_eq!(Slp::get_validators(MOVR), Some(empty_bounded_vec)); + assert_eq!(Validators::::get(MOVR), Some(empty_bounded_vec)); }); } @@ -1673,7 +1673,7 @@ fn reset_validators_should_work() { assert_ok!(Slp::reset_validators(RuntimeOrigin::signed(ALICE), MOVR, validator_list_input)); - assert_eq!(Slp::get_validators(MOVR), Some(validator_list_output)); + assert_eq!(Validators::::get(MOVR), Some(validator_list_output)); }); } @@ -1709,9 +1709,9 @@ fn set_validator_boost_list_should_work() { let bounded_validator_list_output_1 = BoundedVec::try_from(validator_list_output_1).unwrap(); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(bounded_validator_list_output_1)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(bounded_validator_list_output_1)); let bounded_validator_0 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_validator_0)); + assert_eq!(Validators::::get(MOVR), Some(bounded_validator_0)); System::set_block_number(400); @@ -1723,10 +1723,10 @@ fn set_validator_boost_list_should_work() { let bounded_validator_list_output_2 = BoundedVec::try_from(validator_list_output_2).unwrap(); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(bounded_validator_list_output_2)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(bounded_validator_list_output_2)); let bounded_validator_0_1 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION, VALIDATOR_1_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_validator_0_1),); + assert_eq!(Validators::::get(MOVR), Some(bounded_validator_0_1),); }); } @@ -1754,10 +1754,10 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(validator_list_output_1)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(validator_list_output_1)); let bounded_validator_0 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_validator_0.clone())); + assert_eq!(Validators::::get(MOVR), Some(bounded_validator_0.clone())); System::set_block_number(400); @@ -1767,9 +1767,9 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_validator_0)); + assert_eq!(Validators::::get(MOVR), Some(bounded_validator_0)); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(validator_list_output_2)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(validator_list_output_2)); assert_ok!(Slp::add_to_validator_boost_list( RuntimeOrigin::signed(ALICE), @@ -1777,10 +1777,10 @@ fn add_to_validator_boost_list_should_work() { Box::new(VALIDATOR_1_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(validator_list_output_3)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(validator_list_output_3)); let bounded_validator_0_1 = BoundedVec::try_from(vec![VALIDATOR_0_LOCATION, VALIDATOR_1_LOCATION]).unwrap(); - assert_eq!(Slp::get_validators(MOVR), Some(bounded_validator_0_1),); + assert_eq!(Validators::::get(MOVR), Some(bounded_validator_0_1),); }); } @@ -1798,7 +1798,7 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(validator_list_output.clone())); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(validator_list_output.clone())); assert_ok!(Slp::remove_from_validator_boot_list( RuntimeOrigin::signed(ALICE), @@ -1806,7 +1806,7 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_1_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MOVR), Some(validator_list_output)); + assert_eq!(ValidatorBoostList::::get(MOVR), Some(validator_list_output)); assert_ok!(Slp::remove_from_validator_boot_list( RuntimeOrigin::signed(ALICE), @@ -1814,6 +1814,6 @@ fn remove_from_validator_boost_list_should_work() { Box::new(VALIDATOR_0_LOCATION) )); - assert_eq!(Slp::get_validator_boost_list(MOVR), None); + assert_eq!(ValidatorBoostList::::get(MOVR), None); }); } diff --git a/pallets/slp/src/tests/parachain_staking_tests.rs b/pallets/slp/src/tests/parachain_staking_tests.rs index 69a8758c5..4e9889a13 100644 --- a/pallets/slp/src/tests/parachain_staking_tests.rs +++ b/pallets/slp/src/tests/parachain_staking_tests.rs @@ -885,7 +885,7 @@ fn add_validator_and_remove_validator_works() { valis.push(validator_0_location); let bounded_valis = BoundedVec::try_from(valis).unwrap(); - assert_eq!(Slp::get_validators(BNC), Some(bounded_valis)); + assert_eq!(Validators::::get(BNC), Some(bounded_valis)); assert_ok!(Slp::remove_validator( RuntimeOrigin::signed(ALICE), @@ -894,7 +894,7 @@ fn add_validator_and_remove_validator_works() { )); let empty_bounded_vec = BoundedVec::default(); - assert_eq!(Slp::get_validators(BNC), Some(empty_bounded_vec)); + assert_eq!(Validators::::get(BNC), Some(empty_bounded_vec)); }); } diff --git a/pallets/slp/src/tests/phala_tests.rs b/pallets/slp/src/tests/phala_tests.rs index c81be3d3a..f5a930017 100644 --- a/pallets/slp/src/tests/phala_tests.rs +++ b/pallets/slp/src/tests/phala_tests.rs @@ -1408,7 +1408,7 @@ fn add_validator_and_remove_validator_works() { valis.push(VALIDATOR_0_LOCATION); let bounded_valis = BoundedVec::try_from(valis).unwrap(); - assert_eq!(Slp::get_validators(PHA), Some(bounded_valis)); + assert_eq!(Validators::::get(PHA), Some(bounded_valis)); assert_ok!(Slp::delegate( RuntimeOrigin::signed(ALICE), @@ -1425,7 +1425,7 @@ fn add_validator_and_remove_validator_works() { )); let empty_bounded_vec = BoundedVec::default(); - assert_eq!(Slp::get_validators(PHA), Some(empty_bounded_vec)); + assert_eq!(Validators::::get(PHA), Some(empty_bounded_vec)); }); }