Skip to content

Commit

Permalink
fix: encode transaction hash correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Nov 24, 2024
1 parent 35167ae commit 2740493
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion silverback/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def compute_block_time() -> int:
self.block_time = self.chain_manager.provider.network.block_time or compute_block_time()

def pre_send(self, message: TaskiqMessage) -> TaskiqMessage:
# TODO: Necessary because bytes/HexBytes doesn't encode/deocde well for some reason
# TODO: Necessary because bytes/HexBytes doesn't encode/decode well for some reason
def fix_dict(data: dict, recurse_count: int = 0) -> dict:
fixed_data: dict[str, Any] = {}
for name, value in data.items():
if isinstance(value, bytes):
fixed_data[name] = to_hex(value)
elif name == "transaction_hash" and isinstance(value, list):
# TODO: Why is it a list now? (as of Ape v0.8.19ish)
fixed_data[name] = to_hex(bytearray(value))
elif isinstance(value, dict):
if recurse_count > 3:
raise RecursionError("Event object is too deep")
Expand Down

0 comments on commit 2740493

Please sign in to comment.