Skip to content

Commit 7c84c22

Browse files
committed
More review comments
1 parent 9ffcdc9 commit 7c84c22

File tree

8 files changed

+41
-39
lines changed

8 files changed

+41
-39
lines changed

cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,31 +2094,31 @@ fn session_keys_are_compatible_between_ah_and_rc() {
20942094
#[test]
20952095
fn burn_redirects_to_dap_buffer() {
20962096
ExtBuilder::<Runtime>::default().build().execute_with(|| {
2097-
let user: AccountId = BOB.into();
2098-
let initial_balance = 100 * UNITS;
2099-
let burn_amount = 10 * UNITS;
2097+
let user: AccountId = BOB.into();
2098+
let initial_balance = 100 * UNITS;
2099+
let burn_amount = 10 * UNITS;
21002100

2101-
// Given: user has initial balance and DAP buffer exists with ED.
2102-
assert_ok!(Balances::mint_into(&user, initial_balance));
2101+
// Given: user has initial balance and DAP buffer exists with ED.
2102+
assert_ok!(Balances::mint_into(&user, initial_balance));
21032103

2104-
let dap_buffer = Dap::buffer_account();
2105-
let initial_dap_balance = Balances::free_balance(&dap_buffer);
2106-
let initial_issuance = Balances::total_issuance();
2107-
let initial_active_issuance = Balances::active_issuance();
2104+
let dap_buffer = Dap::buffer_account();
2105+
let initial_dap_balance = Balances::free_balance(&dap_buffer);
2106+
let initial_issuance = Balances::total_issuance();
2107+
let initial_active_issuance = Balances::active_issuance();
21082108

2109-
// When: user burns some tokens.
2110-
assert_ok!(Balances::burn(RuntimeOrigin::signed(user.clone()), burn_amount, false));
2109+
// When: user burns some tokens.
2110+
assert_ok!(Balances::burn(RuntimeOrigin::signed(user.clone()), burn_amount, false));
21112111

2112-
// Then: DAP buffer receives the burned amount.
2113-
assert_eq!(Balances::free_balance(&dap_buffer), initial_dap_balance + burn_amount);
2112+
// Then: DAP buffer receives the burned amount.
2113+
assert_eq!(Balances::free_balance(&dap_buffer), initial_dap_balance + burn_amount);
21142114

2115-
// And: user's balance is reduced.
2116-
assert_eq!(Balances::free_balance(&user), initial_balance - burn_amount);
2115+
// And: user's balance is reduced.
2116+
assert_eq!(Balances::free_balance(&user), initial_balance - burn_amount);
21172117

2118-
// And: total issuance is unchanged (funds redirected, not destroyed).
2119-
assert_eq!(Balances::total_issuance(), initial_issuance);
2118+
// And: total issuance is unchanged (funds redirected, not destroyed).
2119+
assert_eq!(Balances::total_issuance(), initial_issuance);
21202120

2121-
// And: active issuance is reduced (funds deactivated, excluded from governance).
2122-
assert_eq!(Balances::active_issuance(), initial_active_issuance - burn_amount);
2123-
});
2121+
// And: active issuance is reduced (funds deactivated, excluded from governance).
2122+
assert_eq!(Balances::active_issuance(), initial_active_issuance - burn_amount);
2123+
});
21242124
}

cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use sp_runtime::{
4848
generic, impl_opaque_keys,
4949
traits::Block as BlockT,
5050
transaction_validity::{TransactionSource, TransactionValidity},
51-
ApplyExtrinsicResult,
51+
ApplyExtrinsicResult, Percent,
5252
};
5353

5454
use sp_session::OpaqueGeneratedSessionKeys;
@@ -363,8 +363,8 @@ impl pallet_balances::Config for Runtime {
363363
parameter_types! {
364364
/// Relay Chain `TransactionByteFee` / 10
365365
pub const TransactionByteFee: Balance = MILLICENTS;
366-
/// Percentage of fees to send to DAP satellite (0 = all to staking pot, 100 = all to DAP).
367-
pub const DapSatelliteFeePercent: u32 = 0;
366+
/// Percentage of fees to send to DAP satellite. 0% = all to staking pot.
367+
pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0);
368368
}
369369

370370
/// Fee handler that splits fees between DAP satellite and staking pot.

cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use sp_runtime::{
6262
generic, impl_opaque_keys,
6363
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT},
6464
transaction_validity::{TransactionSource, TransactionValidity},
65-
ApplyExtrinsicResult, Perbill,
65+
ApplyExtrinsicResult, Perbill, Percent,
6666
};
6767

6868
#[cfg(feature = "std")]
@@ -240,7 +240,7 @@ impl pallet_balances::Config for Runtime {
240240
parameter_types! {
241241
/// Relay Chain `TransactionByteFee` / 10
242242
pub const TransactionByteFee: Balance = MILLICENTS;
243-
pub const DapSatelliteFeePercent: u32 = 0;
243+
pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0);
244244
}
245245

246246
type DealWithFeesSatellite =

cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use sp_runtime::{
7171
generic, impl_opaque_keys,
7272
traits::{BlakeTwo256, Block as BlockT, BlockNumberProvider},
7373
transaction_validity::{TransactionSource, TransactionValidity},
74-
ApplyExtrinsicResult, Debug, DispatchError, MultiAddress, Perbill,
74+
ApplyExtrinsicResult, Debug, DispatchError, MultiAddress, Perbill, Percent,
7575
};
7676
use sp_session::OpaqueGeneratedSessionKeys;
7777
#[cfg(feature = "std")]
@@ -275,8 +275,8 @@ impl pallet_balances::Config for Runtime {
275275
parameter_types! {
276276
/// Relay Chain `TransactionByteFee` / 10
277277
pub const TransactionByteFee: Balance = MILLICENTS;
278-
/// Percentage of fees to send to DAP satellite (0-100). Currently 0% - all fees go to collators.
279-
pub const DapSatelliteFeePercent: u32 = 0;
278+
/// Percentage of fees to send to DAP satellite. Currently 0% - all fees go to collators.
279+
pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0);
280280
}
281281

282282
pub type DealWithFeesSatellite =

cumulus/parachains/runtimes/people/people-westend/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use sp_runtime::{
6464
transaction_validity::{TransactionSource, TransactionValidity},
6565
ApplyExtrinsicResult,
6666
};
67-
pub use sp_runtime::{MultiAddress, Perbill, Permill};
67+
pub use sp_runtime::{MultiAddress, Perbill, Percent, Permill};
6868
use sp_statement_store::{
6969
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
7070
SignatureVerificationResult, Statement,
@@ -251,7 +251,7 @@ impl pallet_balances::Config for Runtime {
251251
parameter_types! {
252252
/// Relay Chain `TransactionByteFee` / 10.
253253
pub const TransactionByteFee: Balance = MILLICENTS;
254-
pub const DapSatelliteFeePercent: u32 = 0;
254+
pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0);
255255
}
256256

257257
type DealWithFeesSatellite =

polkadot/runtime/westend/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,10 @@ parameter_types! {
480480
/// This value increases the priority of `Operational` transactions by adding
481481
/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
482482
pub const OperationalFeeMultiplier: u8 = 5;
483-
/// Percentage of fees that go to DAP satellite (0-100).
483+
/// Percentage of fees that go to DAP satellite.
484484
/// The remainder goes to block author. Tips always go 100% to author.
485485
/// Westend: 0% to DAP (preserving original behavior of 100% to author)
486-
pub const DapSatelliteFeePercent: u32 = 0;
486+
pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0);
487487
}
488488

489489
/// Fee handler that splits fees between DAP satellite and block author.

substrate/frame/dap-satellite/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ use frame_support::{
7979
},
8080
PalletId,
8181
};
82+
use sp_runtime::Percent;
8283

8384
pub use pallet::*;
8485

@@ -231,7 +232,7 @@ pub type CreditOf<T> = Credit<<T as frame_system::Config>::AccountId, <T as Conf
231232

232233
/// A configurable fee handler that splits fees between DAP satellite and another destination.
233234
///
234-
/// - `DapPercent`: Percentage of fees (0-100) to send to DAP satellite
235+
/// - `DapPercent`: Percentage of fees to send to DAP satellite (e.g., `Percent::from_percent(0)`)
235236
/// - `OtherHandler`: Where to send the remaining fees (e.g., `ToAuthor`, `DealWithFees`)
236237
///
237238
/// Tips always go 100% to `OtherHandler`.
@@ -240,7 +241,7 @@ pub type CreditOf<T> = Credit<<T as frame_system::Config>::AccountId, <T as Conf
240241
///
241242
/// ```ignore
242243
/// parameter_types! {
243-
/// pub const DapSatelliteFeePercent: u32 = 0; // 0% to DAP, 100% to staking
244+
/// pub const DapSatelliteFeePercent: Percent = Percent::from_percent(0); // 0% to DAP
244245
/// }
245246
///
246247
/// type DealWithFeesSatellite = pallet_dap_satellite::DealWithFeesSplit<
@@ -261,12 +262,12 @@ impl<T, DapPercent, OtherHandler> OnUnbalanced<CreditOf<T>>
261262
for DealWithFeesSplit<T, DapPercent, OtherHandler>
262263
where
263264
T: Config,
264-
DapPercent: Get<u32>,
265+
DapPercent: Get<Percent>,
265266
OtherHandler: OnUnbalanced<CreditOf<T>>,
266267
{
267268
fn on_unbalanceds(mut fees_then_tips: impl Iterator<Item = CreditOf<T>>) {
268269
if let Some(fees) = fees_then_tips.next() {
269-
let dap_percent = DapPercent::get();
270+
let dap_percent = DapPercent::get().deconstruct() as u32;
270271
let other_percent = 100u32.saturating_sub(dap_percent);
271272
let mut split = fees.ration(dap_percent, other_percent);
272273
if let Some(tips) = fees_then_tips.next() {

substrate/frame/dap-satellite/src/tests/deal_with_fees_split.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use crate::{mock::*, CreditOf, DealWithFeesSplit};
2121
use frame_support::{parameter_types, traits::OnUnbalanced};
2222
use pallet_balances::Pallet as BalancesPallet;
23+
use sp_runtime::Percent;
2324
use std::cell::Cell;
2425

2526
type DapSatellitePallet = crate::Pallet<Test>;
@@ -49,9 +50,9 @@ fn get_other_handler_received() -> u64 {
4950
}
5051

5152
parameter_types! {
52-
pub const ZeroPercent: u32 = 0;
53-
pub const FiftyPercent: u32 = 50;
54-
pub const HundredPercent: u32 = 100;
53+
pub const ZeroPercent: Percent = Percent::from_percent(0);
54+
pub const FiftyPercent: Percent = Percent::from_percent(50);
55+
pub const HundredPercent: Percent = Percent::from_percent(100);
5556
}
5657

5758
#[test]

0 commit comments

Comments
 (0)