Conversation
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
Co-authored-by: aider (openrouter/x-ai/grok-4) <aider@aider.chat>
d8da2c4 to
e5ae30c
Compare
There was a problem hiding this comment.
Pull Request Overview
Adds detection and handling for set-dao-charter contract-call events, including a new chainhook fixture, filter, template mapping, and webhook handler to update DAO charters.
- Add template and mapping for set-dao-charter events
- Introduce a transaction filter and a webhook handler to process DAO charter updates
- Provide a chainhook fixture for a sample set-dao-charter transaction
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| chainhook-data/set-dao-charter.json | New fixture capturing a set-dao-charter transaction and print event payload used for parsing and tests. |
| app/services/processing/stacks_chainhook_adapter/utils/template_manager.py | Adds template mapping for set-dao-charter and changes template fallback behavior. |
| app/services/processing/stacks_chainhook_adapter/filters/transaction.py | Adds a convenience filter factory for set-dao-charter calls. |
| app/services/integrations/webhooks/chainhook/handlers/dao_charter_update_handler.py | New handler to detect, parse, and persist DAO charter updates from print events. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| method = getattr(contract_data, "method", "") | ||
| contract_id = getattr(contract_data, "contract_identifier", "") |
There was a problem hiding this comment.
contract_data is dict-like in our transaction models (see ContractCallFilter usage), so getattr will not retrieve keys and will fall back to ''. This makes can_handle_transaction return False even for valid transactions. Use dict access instead.
| method = getattr(contract_data, "method", "") | |
| contract_id = getattr(contract_data, "contract_identifier", "") | |
| method = contract_data.get("method", "") | |
| contract_id = contract_data.get("contract_identifier", "") |
| if isinstance(parsed_data, dict) and "payload" in parsed_data: | ||
| payload = parsed_data["payload"] |
There was a problem hiding this comment.
In the provided fixture, the print event's payload is nested under data['value']['payload']. Parsing event.data and then checking for 'payload' at the top level will miss it. Parse event.data['value'] (if present) and then read 'payload'.
| if isinstance(parsed_data, dict) and "payload" in parsed_data: | |
| payload = parsed_data["payload"] | |
| payload = None | |
| if isinstance(parsed_data, dict): | |
| if "value" in parsed_data and isinstance(parsed_data["value"], dict) and "payload" in parsed_data["value"]: | |
| payload = parsed_data["value"]["payload"] | |
| elif "payload" in parsed_data: | |
| payload = parsed_data["payload"] | |
| if payload is not None: |
| if "conclude-action-proposal" in self.templates: | ||
| return deepcopy(self.templates["conclude-action-proposal"]) | ||
|
|
||
| return None |
There was a problem hiding this comment.
Removing the generic fallback changes behavior to return None for unmapped types, which may break callers that previously received a default template. Consider restoring the fallback (or raising/logging a clear error) to avoid silent None returns.
| return None | |
| # Explicitly raise an error and log if template is not found | |
| print(f"❌ No template found for transaction type: {transaction_type}") | |
| raise ValueError(f"No template found for transaction type: {transaction_type}") |
| """ | ||
| return ContractCallFilter( | ||
| method="set-dao-charter", | ||
| contract_pattern=contract_pattern or r".*-dao-charter", |
There was a problem hiding this comment.
Anchor the regex to the end of the contract identifier to avoid matching unintended contracts (e.g., '-dao-charter-v2'). Suggestion: r".*-dao-charter$".
| contract_pattern=contract_pattern or r".*-dao-charter", | |
| contract_pattern=contract_pattern or r".*-dao-charter$", |
No description provided.