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
+3 -3
View File
@@ -1229,9 +1229,9 @@ dependencies = [
[[package]]
name = "evm"
version = "0.14.1"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a2c6961fdc9952371fc5f0416f03a9d90378a9dfb6862f6a7a9a3b8986b8dd"
checksum = "73f887b371f9999682ccc5b1cb771e7d4408ae61e93fc0343ceaeb761fca42d1"
dependencies = [
"evm-core",
"evm-gasometer",
@@ -8190,7 +8190,7 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56"
dependencies = [
"rand 0.7.3",
"rand 0.3.23",
]
[[package]]
+1 -1
View File
@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 212,
spec_version: 213,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
+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),