mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 20:15:40 +00:00
Add deposit/withdraw events to EVM module (#5440)
* Add deposit/withdraw events * Remove balances trait
This commit is contained in:
@@ -172,7 +172,7 @@ impl<'vicinity, T: Trait> ApplyBackend for Backend<'vicinity, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for log in logs {
|
for log in logs {
|
||||||
Module::<T>::deposit_event(Event::Log(Log {
|
Module::<T>::deposit_event(Event::<T>::Log(Log {
|
||||||
address: log.address,
|
address: log.address,
|
||||||
topics: log.topics,
|
topics: log.topics,
|
||||||
data: log.data,
|
data: log.data,
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
|
|||||||
/// Currency type for deposit and withdraw.
|
/// Currency type for deposit and withdraw.
|
||||||
type Currency: Currency<Self::AccountId>;
|
type Currency: Currency<Self::AccountId>;
|
||||||
/// The overarching event type.
|
/// The overarching event type.
|
||||||
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
|
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||||
/// Precompiles associated with this EVM engine.
|
/// Precompiles associated with this EVM engine.
|
||||||
type Precompiles: Precompiles;
|
type Precompiles: Precompiles;
|
||||||
|
|
||||||
@@ -147,11 +147,17 @@ decl_storage! {
|
|||||||
|
|
||||||
decl_event! {
|
decl_event! {
|
||||||
/// EVM events
|
/// EVM events
|
||||||
pub enum Event {
|
pub enum Event<T> where
|
||||||
|
<T as frame_system::Trait>::AccountId,
|
||||||
|
{
|
||||||
/// Ethereum events from contracts.
|
/// Ethereum events from contracts.
|
||||||
Log(Log),
|
Log(Log),
|
||||||
/// A contract has been created at given address.
|
/// A contract has been created at given address.
|
||||||
Created(H160),
|
Created(H160),
|
||||||
|
/// A deposit has been made at a given address.
|
||||||
|
BalanceDeposit(AccountId, H160, U256),
|
||||||
|
/// A withdrawal has been made from a given address.
|
||||||
|
BalanceWithdraw(AccountId, H160, U256),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +208,7 @@ decl_module! {
|
|||||||
Accounts::mutate(&address, |account| {
|
Accounts::mutate(&address, |account| {
|
||||||
account.balance += bvalue;
|
account.balance += bvalue;
|
||||||
});
|
});
|
||||||
|
Module::<T>::deposit_event(Event::<T>::BalanceDeposit(sender, address, bvalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Withdraw balance from EVM into currency/balances module.
|
/// Withdraw balance from EVM into currency/balances module.
|
||||||
@@ -225,6 +232,7 @@ decl_module! {
|
|||||||
Accounts::insert(&address, account);
|
Accounts::insert(&address, account);
|
||||||
|
|
||||||
T::Currency::resolve_creating(&sender, imbalance);
|
T::Currency::resolve_creating(&sender, imbalance);
|
||||||
|
Module::<T>::deposit_event(Event::<T>::BalanceWithdraw(sender, address, bvalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Issue an EVM call operation. This is similar to a message call transaction in Ethereum.
|
/// Issue an EVM call operation. This is similar to a message call transaction in Ethereum.
|
||||||
@@ -289,7 +297,7 @@ decl_module! {
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Module::<T>::deposit_event(Event::Created(create_address));
|
Module::<T>::deposit_event(Event::<T>::Created(create_address));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +335,7 @@ decl_module! {
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Module::<T>::deposit_event(Event::Created(create_address));
|
Module::<T>::deposit_event(Event::<T>::Created(create_address));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user