Skip to content

Commit badae21

Browse files
committed
claim type
1 parent 12b7af2 commit badae21

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ pub mod pallet {
334334
Swap,
335335
/// Keep all alpha emission.
336336
Keep,
337+
/// Delegate choice to subnet.
338+
Delegated,
337339
}
338340

339341
/// Enum for the per-coldkey root claim frequency setting.
@@ -359,7 +361,11 @@ pub mod pallet {
359361
/// This is set by the user. Either swap to TAO or keep as alpha.
360362
#[pallet::type_value]
361363
pub fn DefaultRootClaimType<T: Config>() -> RootClaimTypeEnum {
362-
RootClaimTypeEnum::default()
364+
RootClaimTypeEnum::Delegated
365+
}
366+
#[pallet::type_value]
367+
pub fn DefaultDelegateClaimType<T: Config>() -> RootClaimTypeEnum {
368+
RootClaimTypeEnum::Swap
363369
}
364370

365371
/// Default number of root claims per claim call.

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,16 @@ mod dispatches {
24402440
Self::coldkey_owns_hotkey(coldkey.clone(), hotkey.clone()),
24412441
Error::<T>::NonAssociatedColdKey
24422442
);
2443+
2444+
// Ensure the delegate claim type is not Delegated.
2445+
ensure!(
2446+
matches!(
2447+
new_claim_type,
2448+
RootClaimTypeEnum::Swap | RootClaimTypeEnum::Keep
2449+
),
2450+
Error::<T>::InvalidRootClaimType
2451+
);
2452+
24432453
DelegateClaimType::<T>::insert((hotkey.clone(), netuid), new_claim_type.clone());
24442454
Self::deposit_event(Event::DelegateClaimTypeSet {
24452455
hotkey: hotkey.clone(),

pallets/subtensor/src/macros/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,7 @@ mod errors {
266266
InvalidRootClaimThreshold,
267267
/// Exceeded subnet limit number or zero.
268268
InvalidSubnetNumber,
269+
/// Delegates cant set delegated as claim type
270+
InvalidRootClaimType,
269271
}
270272
}

0 commit comments

Comments
 (0)