diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 478fd780b98fa9c4b96540f0501ef98ec174e3f6..ac51ef70e32e2d8994402338b18515db73815ca3 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -281,6 +281,7 @@ decl_module! { } storage::unhashed::put_raw(well_known_keys::CODE, &code); + Self::deposit_event(Event::CodeUpdated); } /// Set the new runtime code without doing any checks of the given `code`. @@ -288,6 +289,7 @@ decl_module! { pub fn set_code_without_checks(origin, code: Vec<u8>) { ensure_root(origin)?; storage::unhashed::put_raw(well_known_keys::CODE, &code); + Self::deposit_event(Event::CodeUpdated); } /// Set the new changes trie configuration. @@ -364,6 +366,8 @@ decl_event!( ExtrinsicSuccess(DispatchInfo), /// An extrinsic failed. ExtrinsicFailed(DispatchError, DispatchInfo), + /// `:code` was updated. + CodeUpdated, } ); @@ -1282,6 +1286,7 @@ mod tests { match e { Event::ExtrinsicSuccess(..) => 100, Event::ExtrinsicFailed(..) => 101, + Event::CodeUpdated => 102, } } } @@ -1688,6 +1693,11 @@ mod tests { RawOrigin::Root.into(), substrate_test_runtime_client::runtime::WASM_BINARY.to_vec(), ).unwrap(); + + assert_eq!( + System::events(), + vec![EventRecord { phase: Phase::ApplyExtrinsic(0), event: 102u16, topics: vec![] }], + ); }); } }