Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alan890104 committed Sep 17, 2023
2 parents 9138f05 + 5cb0440 commit 65dbcb4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions decodex/search/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,19 @@ def simluate_tx(
raise RPCException(resp["error"]["code"], resp["error"]["message"])

logs, account_balance = self._parse_calls(resp["result"])

eth_balance_changes = {}
if len(account_balance) == 0:
eth_balance_changes = {from_address: {"ETH": -value, "Gas Fee": 0}}
eth_balance_changes[from_address] = {NULL_ADDRESS_0x0: -value, NULL_ADDRESS_0xF: 0}
else:
eth_balance_changes = {addr: {"ETH": wei, "Gas Fee": 0} for addr, wei in account_balance.items()}
eth_balance_changes = {
addr: {NULL_ADDRESS_0x0: wei, NULL_ADDRESS_0xF: 0} for addr, wei in account_balance.items()
}

if to_address and self.web3.eth.get_code(to_address).hex() == "0x":
if to_address not in eth_balance_changes:
eth_balance_changes[to_address] = {}
eth_balance_changes[to_address]["ETH"] = value
eth_balance_changes[to_address][NULL_ADDRESS_0x0] = value

result = resp.get("result", {})
tx: Tx = {
Expand Down

0 comments on commit 65dbcb4

Please sign in to comment.