Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Emit ContractCodeUpdated when setting new code_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikbratashchuk committed Jan 20, 2022
1 parent a5a3ec8 commit 7d752fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,10 @@ where
top_frame.contract_info().code_hash = hash;
increment_refcount::<Self::T>(hash)?;
decrement_refcount::<Self::T>(prev_hash)?;
Contracts::<Self::T>::deposit_event(Event::ContractCodeUpdated {
contract: top_frame.account_id.clone(),
code_hash: hash,
});
Ok(())
}

Expand Down
8 changes: 8 additions & 0 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,14 @@ pub mod pallet {

/// A code with the specified hash was removed.
CodeRemoved { code_hash: T::Hash },

/// Contract code has been updated to one specified with code_hash
ContractCodeUpdated {
/// The contract that has been updated.
contract: T::AccountId,
/// New code hash that was set for the contract
code_hash: T::Hash,
},
}

#[pallet::error]
Expand Down

0 comments on commit 7d752fe

Please sign in to comment.