Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comments and usages
  • Loading branch information
ascjones committed Sep 29, 2021
commit c979f35a4f2884682354c1e19327397f24f6f9c2
16 changes: 8 additions & 8 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ where
}

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

Ok(output)
Expand Down Expand Up @@ -942,10 +942,10 @@ where
)?;
ContractInfoOf::<T>::remove(&frame.account_id);
E::remove_user(info.code_hash, &mut frame.nested_meter)?;
Contracts::<T>::deposit_event(Event::Terminated(
frame.account_id.clone(),
beneficiary.clone(),
));
Contracts::<T>::deposit_event(Event::Terminated {
contract: frame.account_id.clone(),
beneficiary: beneficiary.clone(),
});
Ok(())
}

Expand Down Expand Up @@ -997,7 +997,7 @@ where
fn deposit_event(&mut self, topics: Vec<T::Hash>, data: Vec<u8>) {
deposit_event::<Self::T>(
topics,
Event::ContractEmitted(self.top_frame().account_id.clone(), data),
Event::ContractEmitted { contract: self.top_frame().account_id.clone(), data },
);
}

Expand Down Expand Up @@ -1662,7 +1662,7 @@ mod tests {
Storage::<Test>::code_hash(&instantiated_contract_address).unwrap(),
dummy_ch
);
assert_eq!(&events(), &[Event::Instantiated(ALICE, instantiated_contract_address)]);
assert_eq!(&events(), &[Event::Instantiated { deployer: ALICE, contract: instantiated_contract_address }]);
});
}

Expand Down Expand Up @@ -1751,7 +1751,7 @@ mod tests {
Storage::<Test>::code_hash(&instantiated_contract_address).unwrap(),
dummy_ch
);
assert_eq!(&events(), &[Event::Instantiated(BOB, instantiated_contract_address)]);
assert_eq!(&events(), &[Event::Instantiated { deployer: BOB, contract: instantiated_contract_address }]);
});
}

Expand Down
36 changes: 17 additions & 19 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,37 +373,35 @@ pub mod pallet {
Instantiated { deployer: T::AccountId, contract: T::AccountId },

/// Contract has been removed.
/// \[contract, beneficiary\]
///
/// # Params
///
/// - `contract`: The contract that was terminated.
/// - `beneficiary`: The account that received the contracts remaining balance.
///
/// # Note
///
/// The only way for a contract to be removed and emitting this event is by calling
/// `seal_terminate`.
Terminated { contract: T::AccountId, beneficiary: T::AccountId },
Terminated {
/// The contract that was terminated.
contract: T::AccountId,
/// The account that received the contracts remaining balance
beneficiary: T::AccountId
},

/// Code with the specified hash has been stored.
CodeStored { code_hash: T::Hash },

/// Triggered when the current schedule is updated.
///
/// # Params
///
/// - `version`: The version of the newly set schedule.
ScheduleUpdated { version: u32 },
ScheduleUpdated {
/// The version of the newly set schedule.
version: u32
},

/// A custom event emitted by the contract.
///
/// # Params
///
/// - `contract`: The contract that emitted the event.
/// - `data`: Data supplied by the contract. Metadata generated during contract compilation
/// is needed to decode it.
ContractEmitted { contract: T::AccountId, data: Vec<u8> },
ContractEmitted {
/// The contract that emitted the event.
contract: T::AccountId,
/// Data supplied by the contract. Metadata generated during contract compilation
/// is needed to decode it.
data: Vec<u8>
},

/// A code with the specified hash was removed.
///
Expand Down
16 changes: 8 additions & 8 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,20 @@ fn instantiate_and_call_and_deposit_event() {
},
EventRecord {
phase: Phase::Initialization,
event: Event::Contracts(crate::Event::CodeStored(code_hash.into())),
event: Event::Contracts(crate::Event::CodeStored { code_hash: code_hash.into() }),
topics: vec![],
},
EventRecord {
phase: Phase::Initialization,
event: Event::Contracts(crate::Event::ContractEmitted(
addr.clone(),
vec![1, 2, 3, 4]
)),
event: Event::Contracts(crate::Event::ContractEmitted {
contract: addr.clone(),
data: vec![1, 2, 3, 4]
}),
topics: vec![],
},
EventRecord {
phase: Phase::Initialization,
event: Event::Contracts(crate::Event::Instantiated(ALICE, addr.clone())),
event: Event::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() }),
topics: vec![],
},
]
Expand Down Expand Up @@ -764,12 +764,12 @@ fn self_destruct_works() {
},
EventRecord {
phase: Phase::Initialization,
event: Event::Contracts(crate::Event::CodeRemoved(code_hash)),
event: Event::Contracts(crate::Event::CodeRemoved { code_hash }),
topics: vec![],
},
EventRecord {
phase: Phase::Initialization,
event: Event::Contracts(crate::Event::Terminated(addr.clone(), DJANGO)),
event: Event::Contracts(crate::Event::Terminated { contract: addr.clone(), beneficiary: DJANGO }),
topics: vec![],
},
],
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/src/wasm/code_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
Some(module) => increment_64(&mut module.refcount),
None => {
*existing = Some(prefab_module);
Contracts::<T>::deposit_event(Event::CodeStored(code_hash))
Contracts::<T>::deposit_event(Event::CodeStored { code_hash })
},
});
}
Expand Down Expand Up @@ -170,7 +170,7 @@ where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
{
<PristineCode<T>>::remove(code_hash);
Contracts::<T>::deposit_event(Event::CodeRemoved(code_hash))
Contracts::<T>::deposit_event(Event::CodeRemoved { code_hash })
}

/// Increment the refcount panicking if it should ever overflow (which will not happen).
Expand Down