From b7887df104981bc9ce55bf1991262f70dc7bf446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= <bkchr@users.noreply.github.com> Date: Fri, 24 Jan 2020 13:38:45 +0100 Subject: [PATCH] Deposit event on `frame-system::set_code` (#4726) * Deposit event on `frame-system::set_code` * Update frame/system/src/lib.rs Co-authored-by: thiolliere <gui.thiolliere@gmail.com> --- substrate/frame/system/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 478fd780b98..ac51ef70e32 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![] }], + ); }); } } -- GitLab