pallet-evm: log created address (#4821)

* pallet-evm: log created address

* Bump spec_version

* Only emit Created event when ExitReason is Succeed
This commit is contained in:
Wei Tang
2020-02-04 16:58:23 +01:00
committed by GitHub
parent 0ab013bddb
commit 710ffebcca
3 changed files with 11 additions and 5 deletions
+7 -1
View File
@@ -174,6 +174,8 @@ decl_event! {
pub enum Event {
/// Ethereum events from contracts.
Log(Log),
/// A contract has been created at given address.
Created(H160),
}
}
@@ -343,6 +345,7 @@ decl_module! {
}
executor.withdraw(source, total_fee).map_err(|_| Error::<T>::WithdrawFailed)?;
let create_address = executor.create_address(source, evm::CreateScheme::Dynamic);
let reason = executor.transact_create(
source,
value,
@@ -351,7 +354,10 @@ decl_module! {
);
let ret = match reason {
ExitReason::Succeed(_) => Ok(()),
ExitReason::Succeed(_) => {
Module::<T>::deposit_event(Event::Created(create_address));
Ok(())
},
ExitReason::Error(_) => Err(Error::<T>::ExitReasonFailed),
ExitReason::Revert(_) => Err(Error::<T>::ExitReasonRevert),
ExitReason::Fatal(_) => Err(Error::<T>::ExitReasonFatal),