Skip to content

Commit

Permalink
refactor: simplify return
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Mar 7, 2024
1 parent 59e4e99 commit 747ebcb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtime/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ where
let sender = env.ext().caller();
let origin: T::RuntimeOrigin = RawOrigin::Signed(sender.account_id()?.clone()).into();

let result = call.dispatch(origin);
match result {
match call.dispatch(origin) {
Ok(info) => {
log::debug!(target:LOG_TARGET, "{} success, actual weight: {:?}", LOG_PREFIX, info.actual_weight);

// refund weight if the actual weight is less than the charged weight
if let Some(actual_weight) = info.actual_weight {
env.adjust_weight(charged_dispatch_weight, actual_weight);
}

Ok(())
},
Err(err) => {
log::debug!(target:LOG_TARGET, "{} failed: error: {:?}", LOG_PREFIX, err.error);
return Err(err.error);
Err(err.error)
},
}
Ok(())
}

fn read_state<T, E>(env: Environment<E, InitState>) -> Result<(), DispatchError>
Expand Down

0 comments on commit 747ebcb

Please sign in to comment.