|
21 | 21 |
|
22 | 22 | from ethereum.crypto.hash import Hash32, keccak256
|
23 | 23 | from ethereum.exceptions import EthereumException
|
| 24 | +from ethereum.utils.byte import right_pad_zero_bytes |
24 | 25 |
|
25 | 26 | from ..blocks import Log
|
26 | 27 | from ..fork_types import Address, VersionedHash
|
@@ -174,13 +175,24 @@ def transfer_log(
|
174 | 175 | transfer_amount :
|
175 | 176 | The amount of ETH transacted
|
176 | 177 | """
|
177 |
| - # TODO Hash32 implicit conversion will not work here because it doesn't |
178 |
| - # know the direction to pad. |
179 |
| - # We will need to pre-pad the Address correctly before converting, |
| 178 | + import pdb |
| 179 | + |
| 180 | + breakpoint() |
| 181 | + writablelog = "".join(str(log) for log in evm.logs) |
| 182 | + with open("/tmp/txlog.log", "w") as newlog: |
| 183 | + newlog.write(writablelog) |
| 184 | + |
| 185 | + # We need to pre-pad the Address correctly before converting, |
180 | 186 | # otherwise it will throw because the lengths are not the same
|
| 187 | + padded_sender = right_pad_zero_bytes(sender, 12) |
| 188 | + padded_recipient = right_pad_zero_bytes(recipient, 12) |
181 | 189 | log_entry = Log(
|
182 | 190 | address=evm.message.current_target,
|
183 |
| - topics=(MAGIC_LOG_KHASH, Hash32(sender), Hash32(recipient)), |
| 191 | + topics=( |
| 192 | + MAGIC_LOG_KHASH, # noqa: SC200 |
| 193 | + Hash32(padded_sender), |
| 194 | + Hash32(padded_recipient), |
| 195 | + ), |
184 | 196 | data=transfer_amount.to_be_bytes(),
|
185 | 197 | )
|
186 | 198 |
|
|
0 commit comments