Skip to content

Commit

Permalink
update treasury parameters and mark deprecated to specific test instead
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas committed Oct 17, 2024
1 parent ca1ad2f commit b9be8d7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
8 changes: 4 additions & 4 deletions pallets/xc-asset-config/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

#![allow(deprecated)]
use super::{pallet::Error, pallet::Event, *};
use frame_support::{assert_noop, assert_ok, WeakBoundedVec};
use mock::*;
Expand Down Expand Up @@ -183,7 +182,7 @@ fn change_asset_location_is_ok() {
System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(
Event::AssetLocationChanged {
previous_asset_location: asset_location.clone().into_versioned(),
asset_id: asset_id,
asset_id,
new_asset_location: new_asset_location.clone().into_versioned(),
},
));
Expand Down Expand Up @@ -276,7 +275,7 @@ fn remove_asset_is_ok() {
assert_ok!(XcAssetConfig::remove_asset(RuntimeOrigin::root(), asset_id,));
System::assert_last_event(mock::RuntimeEvent::XcAssetConfig(Event::AssetRemoved {
asset_location: asset_location.clone().into_versioned(),
asset_id: asset_id,
asset_id,
}));

// Assert that storage is empty after successful removal
Expand Down Expand Up @@ -352,7 +351,7 @@ fn public_interfaces_are_ok() {
);
assert!(XcAssetConfig::get_units_per_second(asset_location.clone()).is_none());

// Register ups and expect value value to be returned
// Register ups and expect value to be returned
assert_ok!(XcAssetConfig::set_asset_units_per_second(
RuntimeOrigin::root(),
Box::new(asset_location.clone().into_versioned()),
Expand Down Expand Up @@ -389,6 +388,7 @@ fn different_xcm_versions_are_ok() {
}

#[test]
#[allow(deprecated)]
fn incompatible_versioned_multilocations_are_not_ok() {
ExternalityBuilder::build().execute_with(|| {
// Location that cannot be converted from v2 to v4
Expand Down
5 changes: 4 additions & 1 deletion primitives/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use crate::AccountId;
use frame_support::traits::EitherOfDiverse;
use frame_system::EnsureRoot;
use frame_system::{EnsureRoot, EnsureWithSuccess};

pub type OracleMembershipInst = pallet_membership::Instance1;
pub type MainCouncilMembershipInst = pallet_membership::Instance2;
Expand All @@ -44,6 +44,9 @@ pub type EnsureRootOrTwoThirdsMainCouncil = EitherOfDiverse<
pallet_collective::EnsureProportionAtLeast<AccountId, MainCouncilCollectiveInst, 2, 3>,
>;

pub type TreasurySpender<EnsureOrigin, Balance> =
EnsureWithSuccess<EnsureOrigin, AccountId, Balance>;

pub type EnsureRootOrHalfMainCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, MainCouncilCollectiveInst, 1, 2>,
Expand Down
16 changes: 7 additions & 9 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use astar_primitives::{
EnsureRootOrTwoThirdsCommunityCouncil, EnsureRootOrTwoThirdsMainCouncil,
EnsureRootOrTwoThirdsTechnicalCommittee, MainCouncilCollectiveInst,
MainCouncilMembershipInst, MainTreasuryInst, TechnicalCommitteeCollectiveInst,
TechnicalCommitteeMembershipInst,
TechnicalCommitteeMembershipInst, TreasurySpender,
},
Address, AssetId, Balance, BlockNumber, Hash, Header, Nonce,
};
Expand All @@ -96,6 +96,7 @@ pub use pallet_timestamp::Call as TimestampCall;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

#[cfg(feature = "std")]
/// Wasm binary unwrapped. If built with `BUILD_DUMMY_WASM_BINARY`, the function panics.
pub fn wasm_binary_unwrap() -> &'static [u8] {
Expand Down Expand Up @@ -1019,8 +1020,8 @@ impl pallet_democracy::Config for Runtime {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub MainTreasuryAccount: AccountId = Treasury::account_id();
pub const MaxBalance: Balance = Balance::MAX;
}

impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
Expand All @@ -1045,10 +1046,8 @@ impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
type Paymaster = PayFromAccount<Balances, MainTreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrTwoThirdsMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 30 * MINUTES }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand Down Expand Up @@ -1081,9 +1080,8 @@ impl pallet_treasury::Config<CommunityTreasuryInst> for Runtime {
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrTwoThirdsMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 30 * MINUTES }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand Down
15 changes: 6 additions & 9 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ use astar_primitives::{
EnsureRootOrFourFifthsCommunityCouncil, EnsureRootOrHalfCommunityCouncil,
EnsureRootOrHalfMainCouncil, EnsureRootOrHalfTechnicalCommittee, MainCouncilCollectiveInst,
MainCouncilMembershipInst, MainTreasuryInst, OracleMembershipInst,
TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst,
TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst, TreasurySpender,
},
oracle::{CurrencyAmount, CurrencyId, DummyCombineData, Price},
xcm::AssetLocationIdConverter,
Expand Down Expand Up @@ -1409,8 +1409,8 @@ impl pallet_democracy::Config for Runtime {
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub MainTreasuryAccount: AccountId = Treasury::account_id();
pub const MaxBalance: Balance = Balance::MAX;
}

impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
Expand All @@ -1436,9 +1436,8 @@ impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrHalfMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 3 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand Down Expand Up @@ -1470,10 +1469,8 @@ impl pallet_treasury::Config<CommunityTreasuryInst> for Runtime {
type Paymaster = PayFromAccount<Balances, MainTreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;

// New approach to using treasury, useful for OpenGov but not necessarily for us.
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Only used by 'spend' approach which is disabled
type PayoutPeriod = ConstU32<0>;
type SpendOrigin = TreasurySpender<EnsureRootOrHalfMainCouncil, MaxBalance>;
type PayoutPeriod = ConstU32<{ 3 * DAYS }>;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
Expand Down

0 comments on commit b9be8d7

Please sign in to comment.