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

Commit

Permalink
Frame no longer needs to be mutable (refactoring artifact)
Browse files Browse the repository at this point in the history
  • Loading branch information
athei committed Nov 5, 2021
1 parent 7b8f8ef commit 5858aef
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,18 +653,20 @@ where

// Additional work needs to be performed in case of an instantiation.
if output.is_success() && entry_point == ExportedFunction::Constructor {
let frame = self.top_frame_mut();
let account_id = frame.account_id.clone();
let frame = self.top_frame();

// It is not allowed to terminate a contract inside its constructor.
if let CachedContract::Terminated = frame.contract_info {
if matches!(frame.contract_info, CachedContract::Terminated) {
return Err(Error::<T>::TerminatedInConstructor.into())
}

// Deposit an instantiation event.
deposit_event::<T>(
vec![],
Event::Instantiated { deployer: self.caller().clone(), contract: account_id },
Event::Instantiated {
deployer: self.caller().clone(),
contract: frame.account_id.clone(),
},
);
}

Expand Down Expand Up @@ -743,7 +745,7 @@ where
return
}
if let CachedContract::Cached(contract) = &self.first_frame.contract_info {
<ContractInfoOf<T>>::insert(&self.first_frame.account_id, contract.clone());
<ContractInfoOf<T>>::insert(&self.first_frame.account_id, contract);
}
if let Some(counter) = self.account_counter {
<AccountCounter<T>>::set(counter);
Expand Down

0 comments on commit 5858aef

Please sign in to comment.