Skip to content

Commit

Permalink
chore: add event
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Dare committed Jul 8, 2024
1 parent 6daad1e commit fd980b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pallets/subtensor/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,14 @@ mod events {
<T as frame_system::Config>::AccountId,
>>::Balance,
},
/// A coldkey swap has been scheduled
ColdkeySwapScheduled {
/// The account ID of the old coldkey
old_coldkey: T::AccountId,
/// The account ID of the new coldkey
new_coldkey: T::AccountId,
/// The arbitration block for the coldkey swap
arbitration_block: u64,
},
}
}
9 changes: 8 additions & 1 deletion pallets/subtensor/src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<T: Config> Pallet<T> {
///
/// # Arguments
///
/// * `origin` - The origin of the call, which must be signed by the old coldkey.
/// * `old_coldkey` - The account ID of the old coldkey.
/// * `new_coldkey` - The account ID of the new coldkey.
/// * `work` - The proof of work submitted by the caller.
/// * `block_number` - The block number at which the work was performed.
Expand Down Expand Up @@ -289,6 +289,13 @@ impl<T: Config> Pallet<T> {
ColdkeysToSwapAtBlock::<T>::insert(arbitration_block, key_to_arbitrate_on_this_block);
}

// Emit an event indicating that a coldkey swap has been scheduled
Self::deposit_event(Event::ColdkeySwapScheduled {
old_coldkey: old_coldkey.clone(),
new_coldkey: new_coldkey.clone(),
arbitration_block: ColdkeyArbitrationBlock::<T>::get(old_coldkey),
});

Ok(())
}

Expand Down

0 comments on commit fd980b1

Please sign in to comment.