Skip to content

Commit

Permalink
fix: task ID and persistence discrepancy (#48)
Browse files Browse the repository at this point in the history
* fix: align task names and handler_ids

* fix: .contract_address is correct ContractLog attr

* fix: bad prop ref for event_name on ContractLog

* docs: added minor TODO for future us
  • Loading branch information
mikeshultz authored Dec 5, 2023
1 parent 4426342 commit 96453b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions silverback/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def resolve_task(message: TaskiqMessage) -> Tuple[str, Optional[int], Optional[i
if task_id == "block":
block_number = message.args[0].number
task_id = handler_id_block(block_number)
elif task_id == "event":
elif "event" in task_id:
block_number = message.args[0].block_number
log_index = message.args[0].log_index
task_id = handler_id_event(message.args[0].address, message.args[0].abi.name)
# TODO: Should standardize on event signature here instead of name in case of overloading
task_id = handler_id_event(message.args[0].contract_address, message.args[0].event_name)

return task_id, block_number, log_index

Expand Down
2 changes: 1 addition & 1 deletion silverback/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def handler_id_block(block_number: Optional[int]) -> str:
def handler_id_event(contract_address: Optional[str], event_signature: str) -> str:
"""Return a unique handler ID string for an event"""
# TODO: Under what circumstance can address be None?
return f"event/{contract_address or 'unknown'}/{event_signature}"
return f"{contract_address or 'unknown'}/event/{event_signature}"

0 comments on commit 96453b6

Please sign in to comment.