Skip to content

Conversation

@whoabuddy
Copy link
Contributor

No description provided.

whoabuddy and others added 7 commits October 19, 2025 20:34
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>
@whoabuddy whoabuddy force-pushed the feat/charter-detection branch from d8da2c4 to e5ae30c Compare October 20, 2025 03:34
@whoabuddy whoabuddy requested a review from Copilot October 20, 2025 03:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +40 to +41
method = getattr(contract_data, "method", "")
contract_id = getattr(contract_data, "contract_identifier", "")
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
method = getattr(contract_data, "method", "")
contract_id = getattr(contract_data, "contract_identifier", "")
method = contract_data.get("method", "")
contract_id = contract_data.get("contract_identifier", "")

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +68
if isinstance(parsed_data, dict) and "payload" in parsed_data:
payload = parsed_data["payload"]
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Suggested change
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:

Copilot uses AI. Check for mistakes.
if "conclude-action-proposal" in self.templates:
return deepcopy(self.templates["conclude-action-proposal"])

return None
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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}")

Copilot uses AI. Check for mistakes.
"""
return ContractCallFilter(
method="set-dao-charter",
contract_pattern=contract_pattern or r".*-dao-charter",
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anchor the regex to the end of the contract identifier to avoid matching unintended contracts (e.g., '-dao-charter-v2'). Suggestion: r".*-dao-charter$".

Suggested change
contract_pattern=contract_pattern or r".*-dao-charter",
contract_pattern=contract_pattern or r".*-dao-charter$",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants