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

Commit

Permalink
Expand Executed Event (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest authored Jan 5, 2021
1 parent 6447862 commit 7333a4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 38 deletions.
70 changes: 34 additions & 36 deletions frame/dvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ decl_storage! {
decl_event!(
/// Ethereum pallet events.
pub enum Event {
/// An ethereum transaction was successfully executed. [from, transaction_hash]
Executed(H160, H256, ExitReason),
/// An ethereum transaction was successfully executed. [from, to/contract_address, transaction_hash, exit_reason]
Executed(H160, H160, H256, ExitReason),
}
);

Expand Down Expand Up @@ -138,7 +138,7 @@ decl_module! {
);
let transaction_index = Pending::get().len() as u32;

let (to, info) = Self::execute(
let (to, contract_address, info) = Self::execute(
source,
transaction.input.clone(),
transaction.value,
Expand Down Expand Up @@ -202,7 +202,7 @@ decl_module! {

Pending::append((transaction, status, receipt));

Self::deposit_event(Event::Executed(source, transaction_hash,reason));
Self::deposit_event(Event::Executed(source, contract_address.unwrap_or_default(), transaction_hash, reason));
Ok(Some(T::GasToWeight::gas_to_weight(used_gas.low_u32())).into())
}

Expand Down Expand Up @@ -422,39 +422,37 @@ impl<T: Trait> Module<T> {
nonce: Option<U256>,
action: TransactionAction,
config: Option<evm::Config>,
) -> Result<(Option<H160>, CallOrCreateInfo), DispatchError> {
) -> Result<(Option<H160>, Option<H160>, CallOrCreateInfo), DispatchError> {
match action {
ethereum::TransactionAction::Call(target) => Ok((
Some(target),
CallOrCreateInfo::Call(
T::Runner::call(
from,
target,
input.clone(),
value,
gas_limit.low_u32(),
gas_price,
nonce,
config.as_ref().unwrap_or(T::config()),
)
.map_err(Into::into)?,
),
)),
ethereum::TransactionAction::Create => Ok((
None,
CallOrCreateInfo::Create(
T::Runner::create(
from,
input.clone(),
value,
gas_limit.low_u32(),
gas_price,
nonce,
config.as_ref().unwrap_or(T::config()),
)
.map_err(Into::into)?,
),
)),
ethereum::TransactionAction::Call(target) => {
let res = T::Runner::call(
from,
target,
input.clone(),
value,
gas_limit.low_u32(),
gas_price,
nonce,
config.as_ref().unwrap_or(T::config()),
)
.map_err(Into::into)?;

Ok((Some(target), None, CallOrCreateInfo::Call(res)))
}
ethereum::TransactionAction::Create => {
let res = T::Runner::create(
from,
input.clone(),
value,
gas_limit.low_u32(),
gas_price,
nonce,
config.as_ref().unwrap_or(T::config()),
)
.map_err(Into::into)?;

Ok((None, Some(res.value), CallOrCreateInfo::Create(res)))
}
}
}
}
4 changes: 2 additions & 2 deletions frame/dvm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn transaction_should_generate_correct_gas_used() {

ext.execute_with(|| {
let t = default_erc20_creation_transaction(alice);
let (_, info) = Ethereum::execute(
let (_, _, info) = Ethereum::execute(
alice.address,
t.input,
t.value,
Expand Down Expand Up @@ -296,7 +296,7 @@ fn call_should_handle_errors() {
let bar: Vec<u8> = FromHex::from_hex("febb0f7e").unwrap();

// calling foo will succeed
let (_, info) = Ethereum::execute(
let (_, _, info) = Ethereum::execute(
alice.address,
foo,
U256::zero(),
Expand Down

0 comments on commit 7333a4d

Please sign in to comment.