mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Make SetCode::set_code return a result (#8515)
This commit is contained in:
@@ -94,7 +94,7 @@ use frame_support::{
|
||||
Weight, RuntimeDbWeight, DispatchInfo, DispatchClass,
|
||||
extract_actual_weight, PerDispatchClass,
|
||||
},
|
||||
dispatch::DispatchResultWithPostInfo,
|
||||
dispatch::{DispatchResultWithPostInfo, DispatchResult},
|
||||
};
|
||||
use codec::{Encode, Decode, FullCodec, EncodeLike};
|
||||
|
||||
@@ -143,12 +143,13 @@ pub use pallet::*;
|
||||
/// Do something when we should be setting the code.
|
||||
pub trait SetCode {
|
||||
/// Set the code to the given blob.
|
||||
fn set_code(code: Vec<u8>);
|
||||
fn set_code(code: Vec<u8>) -> DispatchResult;
|
||||
}
|
||||
|
||||
impl SetCode for () {
|
||||
fn set_code(code: Vec<u8>) {
|
||||
fn set_code(code: Vec<u8>) -> DispatchResult {
|
||||
storage::unhashed::put_raw(well_known_keys::CODE, &code);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +346,7 @@ pub mod pallet {
|
||||
ensure_root(origin)?;
|
||||
Self::can_set_code(&code)?;
|
||||
|
||||
T::OnSetCode::set_code(code);
|
||||
T::OnSetCode::set_code(code)?;
|
||||
Self::deposit_event(Event::CodeUpdated);
|
||||
Ok(().into())
|
||||
}
|
||||
@@ -364,7 +365,7 @@ pub mod pallet {
|
||||
code: Vec<u8>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_root(origin)?;
|
||||
T::OnSetCode::set_code(code);
|
||||
T::OnSetCode::set_code(code)?;
|
||||
Self::deposit_event(Event::CodeUpdated);
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user