Skip to content

Commit 7a16a9a

Browse files
committed
refac(permission0): rename emission to streams
1 parent cf4dd6b commit 7a16a9a

File tree

20 files changed

+444
-450
lines changed

20 files changed

+444
-450
lines changed

pallets/emission0/src/distribute.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pallet_governance_api::GovernanceApi;
2-
use pallet_permission0_api::Permission0EmissionApi;
2+
use pallet_permission0_api::Permission0StreamApi;
33
use pallet_torus0_api::Torus0Api;
44
use polkadot_sdk::{
55
frame_support::{
@@ -336,7 +336,7 @@ fn linear_rewards<T: Config>(mut emission: NegativeImbalanceOf<T>) -> NegativeIm
336336
} else {
337337
// This is an impossible case, but if something changes in the future,
338338
// the code is here.
339-
<T::Permission0>::accumulate_emissions(
339+
<T::Permission0>::accumulate_streams(
340340
delegating_to,
341341
&pallet_permission0_api::generate_root_stream_id(delegating_to),
342342
&mut stake,
@@ -368,7 +368,7 @@ fn linear_rewards<T: Config>(mut emission: NegativeImbalanceOf<T>) -> NegativeIm
368368
.zip(upscaled_dividends)
369369
{
370370
let add_stake = |staker, mut amount: NegativeImbalanceOf<T>| {
371-
<T::Permission0>::accumulate_emissions(
371+
<T::Permission0>::accumulate_streams(
372372
&staker,
373373
&pallet_permission0_api::generate_root_stream_id(&staker),
374374
&mut amount,

pallets/emission0/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub mod pallet {
3131
use frame::prelude::BlockNumberFor;
3232
use frame_system::ensure_signed;
3333
use pallet_governance_api::GovernanceApi;
34-
use pallet_permission0_api::{Permission0Api, Permission0EmissionApi};
34+
use pallet_permission0_api::{Permission0Api, Permission0StreamApi};
3535
use pallet_torus0_api::Torus0Api;
3636
use polkadot_sdk::sp_std;
3737
use weights::WeightInfo;
@@ -99,7 +99,7 @@ pub mod pallet {
9999
type Governance: GovernanceApi<Self::AccountId>;
100100

101101
type Permission0: Permission0Api<OriginFor<Self>>
102-
+ Permission0EmissionApi<
102+
+ Permission0StreamApi<
103103
Self::AccountId,
104104
OriginFor<Self>,
105105
BlockNumberFor<Self>,

pallets/emission0/src/weights.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! Autogenerated weights for `pallet_emission0`
33
//!
44
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0
5-
//! DATE: 2025-08-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
5+
//! DATE: 2025-08-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
66
//! WORST CASE MAP SIZE: `1000000`
77
//! HOSTNAME: `Luizs-MacBook-Pro.local`, CPU: `<UNKNOWN>`
88
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024`
@@ -65,7 +65,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6565
// Measured: `677`
6666
// Estimated: `7654`
6767
// Minimum execution time: 26_000_000 picoseconds.
68-
Weight::from_parts(26_000_000, 7654)
68+
Weight::from_parts(27_000_000, 7654)
6969
.saturating_add(T::DbWeight::get().reads(10_u64))
7070
.saturating_add(T::DbWeight::get().writes(1_u64))
7171
}
@@ -94,7 +94,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
9494
// Proof Size summary in bytes:
9595
// Measured: `333`
9696
// Estimated: `3529`
97-
// Minimum execution time: 9_000_000 picoseconds.
97+
// Minimum execution time: 10_000_000 picoseconds.
9898
Weight::from_parts(10_000_000, 3529)
9999
.saturating_add(T::DbWeight::get().reads(2_u64))
100100
.saturating_add(T::DbWeight::get().writes(1_u64))
@@ -122,7 +122,7 @@ impl WeightInfo for () {
122122
// Measured: `677`
123123
// Estimated: `7654`
124124
// Minimum execution time: 26_000_000 picoseconds.
125-
Weight::from_parts(26_000_000, 7654)
125+
Weight::from_parts(27_000_000, 7654)
126126
.saturating_add(RocksDbWeight::get().reads(10_u64))
127127
.saturating_add(RocksDbWeight::get().writes(1_u64))
128128
}
@@ -151,7 +151,7 @@ impl WeightInfo for () {
151151
// Proof Size summary in bytes:
152152
// Measured: `333`
153153
// Estimated: `3529`
154-
// Minimum execution time: 9_000_000 picoseconds.
154+
// Minimum execution time: 10_000_000 picoseconds.
155155
Weight::from_parts(10_000_000, 3529)
156156
.saturating_add(RocksDbWeight::get().reads(2_u64))
157157
.saturating_add(RocksDbWeight::get().writes(1_u64))

pallets/governance/src/weights.rs

Lines changed: 69 additions & 69 deletions
Large diffs are not rendered by default.

pallets/permission0/api/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pub fn generate_root_stream_id<AccountId: Encode>(agent_id: &AccountId) -> Strea
2626
blake2_256(&data).into()
2727
}
2828

29-
/// Defines what portion of emissions the permission applies to
29+
/// Defines what portion of streams the permission applies to
3030
#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, Eq, Debug)]
31-
pub enum EmissionAllocation<Balance> {
31+
pub enum StreamAllocation<Balance> {
3232
/// Permission applies to a percentage of all emissions (0-100)
3333
Streams(BTreeMap<StreamId, Percent>),
3434
/// Permission applies to a specific fixed amount
@@ -100,13 +100,13 @@ pub trait Permission0Api<Origin> {
100100
fn execute_permission(who: Origin, permission_id: &PermissionId) -> DispatchResult;
101101
}
102102

103-
pub trait Permission0EmissionApi<AccountId, Origin, BlockNumber, Balance, NegativeImbalance> {
104-
/// Delegate a permission for emission delegation
103+
pub trait Permission0StreamApi<AccountId, Origin, BlockNumber, Balance, NegativeImbalance> {
104+
/// Delegate a permission for streams delegation
105105
#[allow(clippy::too_many_arguments)]
106-
fn delegate_emission_permission(
106+
fn delegate_stream_permission(
107107
delegator: AccountId,
108108
recipients: Vec<(AccountId, u16)>,
109-
allocation: EmissionAllocation<Balance>,
109+
allocation: StreamAllocation<Balance>,
110110
distribution: DistributionControl<Balance, BlockNumber>,
111111
duration: PermissionDuration<BlockNumber>,
112112
revocation: RevocationTerms<AccountId, BlockNumber>,
@@ -115,8 +115,8 @@ pub trait Permission0EmissionApi<AccountId, Origin, BlockNumber, Balance, Negati
115115
weight_setter: Option<AccountId>,
116116
) -> Result<PermissionId, DispatchError>;
117117

118-
/// Accumulate emissions for an agent with permissions
119-
fn accumulate_emissions(agent: &AccountId, stream: &StreamId, amount: &mut NegativeImbalance);
118+
/// Accumulate streams for an agent with permissions
119+
fn accumulate_streams(agent: &AccountId, stream: &StreamId, amount: &mut NegativeImbalance);
120120

121121
/// Check and process automatic distributions
122122
fn process_auto_distributions(current_block: BlockNumber);

pallets/permission0/src/benchmarking.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod benchmarks {
2828
}
2929

3030
#[benchmark]
31-
fn delegate_emission_permission() {
31+
fn delegate_stream_permission() {
3232
let delegator: T::AccountId = account("delegator", 0, 0);
3333
let recipient: T::AccountId = account("recipient", 1, 0);
3434

@@ -42,15 +42,15 @@ mod benchmarks {
4242

4343
let stream_id: StreamId = [0; 32].into();
4444
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
45-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
45+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
4646
let recipients = bounded_btree_map![recipient => 100];
4747
let distribution = DistributionControl::Manual;
4848
let duration = PermissionDuration::Indefinite;
4949
let revocation = RevocationTerms::RevocableByDelegator;
5050
let enforcement = EnforcementAuthority::None;
5151

5252
#[extrinsic_call]
53-
delegate_emission_permission(
53+
delegate_stream_permission(
5454
RawOrigin::Signed(delegator),
5555
recipients,
5656
allocation,
@@ -78,9 +78,9 @@ mod benchmarks {
7878

7979
let stream_id: StreamId = [0; 32].into();
8080
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
81-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
81+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
8282
let recipients = bounded_btree_map![recipient => 100];
83-
let permission_id = ext::emission_impl::delegate_emission_permission_impl::<T>(
83+
let permission_id = ext::stream_impl::delegate_stream_permission_impl::<T>(
8484
delegator.clone(),
8585
recipients,
8686
allocation,
@@ -114,10 +114,10 @@ mod benchmarks {
114114
// Create permission with fixed amount allocation
115115
let stream_id: StreamId = [0; 32].into();
116116
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
117-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
117+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
118118
let recipients = bounded_btree_map![recipient => 100];
119119

120-
let permission_id = ext::emission_impl::delegate_emission_permission_impl::<T>(
120+
let permission_id = ext::stream_impl::delegate_stream_permission_impl::<T>(
121121
delegator.clone(),
122122
recipients,
123123
allocation,
@@ -153,10 +153,10 @@ mod benchmarks {
153153
// Create permission with stream allocation
154154
let stream_id: StreamId = [0; 32].into();
155155
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
156-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
156+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
157157
let recipients = bounded_btree_map![recipient => 100];
158158

159-
let permission_id = ext::emission_impl::delegate_emission_permission_impl::<T>(
159+
let permission_id = ext::stream_impl::delegate_stream_permission_impl::<T>(
160160
delegator.clone(),
161161
recipients,
162162
allocation,
@@ -192,7 +192,7 @@ mod benchmarks {
192192
// Create permission with fixed amount allocation and enforcement authority
193193
let stream_id: StreamId = [0; 32].into();
194194
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
195-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
195+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
196196
let recipients = bounded_btree_map![recipient => 100];
197197
let controllers = vec![controller.clone()].try_into().unwrap();
198198

@@ -201,7 +201,7 @@ mod benchmarks {
201201
required_votes: 1,
202202
};
203203

204-
let permission_id = ext::emission_impl::delegate_emission_permission_impl::<T>(
204+
let permission_id = ext::stream_impl::delegate_stream_permission_impl::<T>(
205205
delegator.clone(),
206206
recipients,
207207
allocation,
@@ -237,10 +237,10 @@ mod benchmarks {
237237

238238
let stream_id: StreamId = [0; 32].into();
239239
let streams = BTreeMap::from([(stream_id, Percent::from_percent(30))]);
240-
let allocation = EmissionAllocation::Streams(streams.try_into().unwrap());
240+
let allocation = StreamAllocation::Streams(streams.try_into().unwrap());
241241
let recipients = bounded_btree_map![recipient => 100];
242242

243-
let permission_id = ext::emission_impl::delegate_emission_permission_impl::<T>(
243+
let permission_id = ext::stream_impl::delegate_stream_permission_impl::<T>(
244244
delegator.clone(),
245245
recipients,
246246
allocation,

pallets/permission0/src/ext.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use polkadot_sdk::{
1515
};
1616

1717
pub mod curator_impl;
18-
pub mod emission_impl;
1918
pub mod namespace_impl;
19+
pub mod stream_impl;
2020

2121
/// Implementation of the Permission0Api trait to be used externally
2222
impl<T: Config> Permission0Api<OriginFor<T>> for pallet::Pallet<T> {
@@ -141,8 +141,8 @@ pub(crate) fn execute_permission_impl<T: Config>(
141141
);
142142

143143
match &contract.scope {
144-
PermissionScope::Emission(emission_scope) => {
145-
emission_impl::execute_permission_impl(permission_id, &contract, emission_scope)
144+
PermissionScope::Stream(stream_scope) => {
145+
stream_impl::execute_permission_impl(permission_id, &contract, stream_scope)
146146
}
147147
PermissionScope::Curator(_) => curator_impl::execute_permission_impl::<T>(permission_id),
148148
PermissionScope::Namespace(_) => Ok(()),
@@ -201,8 +201,8 @@ pub fn enforcement_execute_permission_impl<T: Config>(
201201
}
202202

203203
match &contract.scope {
204-
PermissionScope::Emission(emission_scope) => {
205-
emission_impl::execute_permission_impl(&permission_id, &contract, emission_scope)?
204+
PermissionScope::Stream(stream_scope) => {
205+
stream_impl::execute_permission_impl(&permission_id, &contract, stream_scope)?
206206
}
207207
PermissionScope::Curator(_) => {
208208
return curator_impl::execute_permission_impl::<T>(&permission_id);

0 commit comments

Comments
 (0)