Skip to content

Commit

Permalink
get initial onchain balance for call receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Raz0r committed Aug 27, 2024
1 parent 6b1c2d8 commit 684a4bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/evm/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ use crate::{
onchain::{
abi_decompiler::fetch_abi_evmole,
flashloan::{register_borrow_txn, Flashloan},
OnChain,
},
types::{as_u64, generate_random_address, is_zero, EVMAddress, EVMU256},
vm::{is_reverted_or_control_leak, EVMState, SinglePostExecution, IN_DEPLOY, IS_FAST_CALL_STATIC},
Expand Down Expand Up @@ -1480,6 +1481,15 @@ where
if let Some(balance) = self.evmstate.get_balance(&receiver) {
self.evmstate.set_balance(receiver, *balance + value);
} else {
let on_chain_middleware = self
.middlewares
.read()
.unwrap()
.iter()
.find_map(|m| m.deref().borrow().as_any().downcast_ref::<OnChain>().cloned());
if let Some(mut on_chain_middleware) = on_chain_middleware {
self.next_slot = on_chain_middleware.endpoint.get_balance(receiver);
}
self.evmstate.set_balance(receiver, self.next_slot + value);
};
}
Expand Down

0 comments on commit 684a4bd

Please sign in to comment.