From 807a0d42b0f1295636ade55b5fdf6b58f518c4ee Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:05:48 -0700 Subject: [PATCH 1/7] chore: update submodule --- agent-tools-ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent-tools-ts b/agent-tools-ts index 7c1b7129..3667c3cf 160000 --- a/agent-tools-ts +++ b/agent-tools-ts @@ -1 +1 @@ -Subproject commit 7c1b712966aac53ddd96e841db1c77af296fde62 +Subproject commit 3667c3cff526c6608711f44c274c3fe35b02b9db From dcb78a724718d68a823b9fd11885e157eb4fe78e Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:25:42 -0700 Subject: [PATCH 2/7] fix: make a pass to remove unused tools --- tools/dao_ext_action_proposals.py | 815 +---------------------------- tools/dao_ext_core_proposals.py | 236 --------- tools/dao_ext_onchain_messaging.py | 73 --- tools/dao_ext_payments_invoices.py | 338 ------------ tools/dao_ext_timed_vault.py | 188 ------- tools/tools_factory.py | 68 --- 6 files changed, 24 insertions(+), 1694 deletions(-) delete mode 100644 tools/dao_ext_core_proposals.py delete mode 100644 tools/dao_ext_onchain_messaging.py delete mode 100644 tools/dao_ext_payments_invoices.py delete mode 100644 tools/dao_ext_timed_vault.py diff --git a/tools/dao_ext_action_proposals.py b/tools/dao_ext_action_proposals.py index eceb1e92..f4417d6f 100644 --- a/tools/dao_ext_action_proposals.py +++ b/tools/dao_ext_action_proposals.py @@ -12,651 +12,8 @@ class DaoBaseInput(BaseModel): pass - -class ProposeActionAddResourceInput(BaseModel): - """Input schema for proposing to add a resource action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2" - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2" - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes adding a resource to the DAO.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-add-resource" - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-add-resource" - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - resource_name: str = Field(..., description="Name of the resource to add") - resource_description: str = Field(..., description="Description of the resource") - resource_price: int = Field(..., description="Price of the resource in microstacks") - resource_url: Optional[str] = Field( - None, - description="Optional URL associated with the resource", - examples=["https://www.example.com/resource"], - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Adding a new consultation resource for the DAO"], - ) - - -class ProposeActionAddResourceTool(BaseTool): - name: str = "dao_propose_action_add_resource" - description: str = ( - "This creates a proposal that DAO members can vote on to add the new resource to the " - " DAO resource contract with specified name, description, price, and optional URL." - ) - args_schema: Type[BaseModel] = ProposeActionAddResourceInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - resource_description: str, - resource_price: int, - resource_url: Optional[str] = None, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose adding a resource.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - resource_description, - str(resource_price), - ] - - if resource_url: - args.append(resource_url) - - if memo: - if not resource_url: - args.append("") # Add empty URL if not provided but memo is - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-add-resource.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - resource_description: str, - resource_price: int, - resource_url: Optional[str] = None, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose adding a resource.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - resource_description, - resource_price, - resource_url, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - resource_description: str, - resource_price: int, - resource_url: Optional[str] = None, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - resource_description, - resource_price, - resource_url, - memo, - **kwargs, - ) - - -class ProposeActionAllowAssetInput(BaseModel): - """Input schema for proposing to allow an asset action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes allowing an asset in the DAO treasury.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-allow-asset", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - dao_token_contract_address_to_allow: str = Field( - ..., - description="Contract principal of the token to allow", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Allow new token for DAO treasury operations"], - ) - - -class ProposeActionAllowAssetTool(BaseTool): - name: str = "dao_propose_action_allow_asset" - description: str = ( - "This creates a proposal that DAO members can vote on to allow a specific " - " token contract to be used within the DAO treasury contract." - ) - args_schema: Type[BaseModel] = ProposeActionAllowAssetInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - dao_token_contract_address_to_allow: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose allowing an asset.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - dao_token_contract_address_to_allow, - ] - - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-allow-asset.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - dao_token_contract_address_to_allow: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose allowing an asset.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - dao_token_contract_address_to_allow, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - dao_token_contract_address_to_allow: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - dao_token_contract_address_to_allow, - memo, - **kwargs, - ) - - -class ProposeActionSendMessageInput(BaseModel): - """Input schema for proposing to send a message action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes sending a message through the DAO.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-send-message", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-send-message", - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - message: str = Field( - ..., - description="Message to be sent through the DAO proposal system, verified to be from the DAO and posted to Twitter/X automatically if successful.", - examples=["gm gm from the $FACES DAO!"], - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Sending a greeting message from our DAO"], - ) - - -class ProposeActionSendMessageTool(BaseTool): - name: str = "dao_propose_action_send_message" - description: str = ( - "This creates a proposal that DAO members can vote on to send a specific message that gets " - "stored on-chain and automatically posted to the DAO Twitter/X account." - ) - args_schema: Type[BaseModel] = ProposeActionSendMessageInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - message: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose sending a message.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - message, - dao_token_contract_address, - ] - - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/public", - "create-action-proposal.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - message: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose sending a message.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - message, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - message: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - message, - memo, - **kwargs, - ) - - -class ProposeActionSetAccountHolderInput(BaseModel): - """Input schema for proposing to set account holder action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes setting the account holder in a DAO timed vault.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-set-account-holder", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-set-account-holder", - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - account_holder: str = Field( - ..., - description="Address of the new account holder", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18", - "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", - "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.contract", - ], - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Setting new account holder for DAO vault"], - ) - - -class ProposeActionSetAccountHolderTool(BaseTool): - name: str = "dao_propose_action_set_account_holder" - description: str = ( - "This creates a proposal that DAO members can vote on to change the account holder " - "in a DAO timed vault to a specified standard or contract address." - ) - args_schema: Type[BaseModel] = ProposeActionSetAccountHolderInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - account_holder: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose setting a new account holder.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - account_holder, - ] - - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-set-account-holder.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - account_holder: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose setting a new account holder.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - account_holder, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - account_holder: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - account_holder, - memo, - **kwargs, - ) - - -class ProposeActionSetWithdrawalAmountInput(BaseModel): - """Input schema for proposing to set withdrawal amount action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes setting the withdrawal amount in a DAO timed vault.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-set-withdrawal-amount", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-set-withdrawal-amount", - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - withdrawal_amount: int = Field( - ..., - description="New withdrawal amount to set in microSTX", - examples=["50000000"], # 50 STX - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Updating withdrawal amount to 50 STX"], - ) - - -class ProposeActionSetWithdrawalAmountTool(BaseTool): - name: str = "dao_propose_action_set_withdrawal_amount" - description: str = ( - "This creates a proposal that DAO members can vote on to change the withdrawal amount " - " to a specified number of microSTX in a DAO timed vault." - ) - args_schema: Type[BaseModel] = ProposeActionSetWithdrawalAmountInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - withdrawal_amount: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose setting a new withdrawal amount.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - str(withdrawal_amount), - ] - - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-set-withdrawal-amount.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - withdrawal_amount: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose setting a new withdrawal amount.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - withdrawal_amount, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - withdrawal_amount: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - withdrawal_amount, - memo, - **kwargs, - ) - - -class ProposeActionSetWithdrawalPeriodInput(BaseModel): - """Input schema for proposing to set withdrawal period action.""" +class ProposeActionSendMessageInput(BaseModel): + """Input schema for proposing to send a message action.""" action_proposals_voting_extension: str = Field( ..., @@ -668,10 +25,10 @@ class ProposeActionSetWithdrawalPeriodInput(BaseModel): ) action_proposal_contract_to_execute: str = Field( ..., - description="Contract principal of the action proposal that executes setting the withdrawal period in a DAO timed vault.", + description="Contract principal of the action proposal that executes sending a message through the DAO.", examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-set-withdrawal-period", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-set-withdrawal-period", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-send-message", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-send-message", ], ) dao_token_contract_address: str = Field( @@ -682,25 +39,25 @@ class ProposeActionSetWithdrawalPeriodInput(BaseModel): "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", ], ) - withdrawal_period: int = Field( + message: str = Field( ..., - description="New withdrawal period to set in Bitcoin blocks", - examples=["144"], # 1 day in BTC blocks + description="Message to be sent through the DAO proposal system, verified to be from the DAO and posted to Twitter/X automatically if successful.", + examples=["gm gm from the $FACES DAO!"], ) memo: Optional[str] = Field( None, description="Optional memo to include with the proposal", - examples=["Updating withdrawal period to 1 day (144 blocks)"], + examples=["Sending a greeting message from our DAO"], ) -class ProposeActionSetWithdrawalPeriodTool(BaseTool): - name: str = "dao_propose_action_set_withdrawal_period" +class ProposeActionSendMessageTool(BaseTool): + name: str = "dao_propose_action_send_message" description: str = ( - "This creates a proposal that DAO members can vote on to change the withdrawal period " - " to a specified number of Bitcoin blocks in a DAO timed vault." + "This creates a proposal that DAO members can vote on to send a specific message that gets " + "stored on-chain and automatically posted to the DAO Twitter/X account." ) - args_schema: Type[BaseModel] = ProposeActionSetWithdrawalPeriodInput + args_schema: Type[BaseModel] = ProposeActionSendMessageInput return_direct: bool = False wallet_id: Optional[UUID] = None @@ -713,19 +70,19 @@ def _deploy( action_proposals_voting_extension: str, action_proposal_contract_to_execute: str, dao_token_contract_address: str, - withdrawal_period: int, + message: str, memo: Optional[str] = None, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to propose setting a new withdrawal period.""" + """Execute the tool to propose sending a message.""" if self.wallet_id is None: return {"success": False, "message": "Wallet ID is required", "data": None} args = [ action_proposals_voting_extension, action_proposal_contract_to_execute, + message, dao_token_contract_address, - str(withdrawal_period), ] if memo: @@ -733,8 +90,8 @@ def _deploy( return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-set-withdrawal-period.ts", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/public", + "create-action-proposal.ts", *args, ) @@ -743,16 +100,16 @@ def _run( action_proposals_voting_extension: str, action_proposal_contract_to_execute: str, dao_token_contract_address: str, - withdrawal_period: int, + message: str, memo: Optional[str] = None, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to propose setting a new withdrawal period.""" + """Execute the tool to propose sending a message.""" return self._deploy( action_proposals_voting_extension, action_proposal_contract_to_execute, dao_token_contract_address, - withdrawal_period, + message, memo, **kwargs, ) @@ -762,7 +119,7 @@ async def _arun( action_proposals_voting_extension: str, action_proposal_contract_to_execute: str, dao_token_contract_address: str, - withdrawal_period: int, + message: str, memo: Optional[str] = None, **kwargs, ) -> Dict[str, Any]: @@ -771,12 +128,11 @@ async def _arun( action_proposals_voting_extension, action_proposal_contract_to_execute, dao_token_contract_address, - withdrawal_period, + message, memo, **kwargs, ) - class VoteOnActionProposalInput(BaseModel): """Input schema for voting on an action proposal.""" @@ -961,129 +317,6 @@ async def _arun( **kwargs, ) - -class ProposeActionToggleResourceInput(BaseModel): - """Input schema for proposing to toggle a resource action.""" - - action_proposals_voting_extension: str = Field( - ..., - description="Contract principal where the DAO creates action proposals for voting by DAO members.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", - ], - ) - action_proposal_contract_to_execute: str = Field( - ..., - description="Contract principal of the action proposal that executes toggling a resource in the DAO.", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-toggle-resource", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-toggle-resource", - ], - ) - dao_token_contract_address: str = Field( - ..., - description="Contract principal of the token used by the DAO for voting", - examples=[ - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-faktory", - "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-faktory", - ], - ) - resource_name: str = Field( - ..., - description="Name of the resource to toggle", - examples=["apiv1", "protected-content", "1hr consulting"], - ) - memo: Optional[str] = Field( - None, - description="Optional memo to include with the proposal", - examples=["Toggling availability of consulting resource"], - ) - - -class ProposeActionToggleResourceTool(BaseTool): - name: str = "dao_propose_action_toggle_resource" - description: str = ( - "This creates a proposal that DAO members can vote on to enable or disable " - "whether a specific resource can be paid for in the DAO resource contract." - ) - args_schema: Type[BaseModel] = ProposeActionToggleResourceInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose toggling a resource.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - ] - - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/action-proposals/public", - "propose-action-toggle-resource-by-name.ts", - *args, - ) - - def _run( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to propose toggling a resource.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - memo, - **kwargs, - ) - - async def _arun( - self, - action_proposals_voting_extension: str, - action_proposal_contract_to_execute: str, - dao_token_contract_address: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - action_proposals_voting_extension, - action_proposal_contract_to_execute, - dao_token_contract_address, - resource_name, - memo, - **kwargs, - ) - - class GetLiquidSupplyInput(BaseModel): """Input schema for getting the liquid supply.""" diff --git a/tools/dao_ext_core_proposals.py b/tools/dao_ext_core_proposals.py deleted file mode 100644 index 7fc11821..00000000 --- a/tools/dao_ext_core_proposals.py +++ /dev/null @@ -1,236 +0,0 @@ -from typing import Any, Dict, Optional, Type -from uuid import UUID - -from langchain.tools import BaseTool -from pydantic import BaseModel, Field - -from tools.bun import BunScriptRunner - - -class GenerateCoreProposalInput(BaseModel): - """Input schema for generating a core proposal.""" - - dao_deployer_address: str = Field( - ..., - description="The address of the DAO deployer", - example="ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", - ) - dao_token_symbol: str = Field( - ..., - description="The token symbol for the DAO", - example="aibtc", - ) - proposal_contract_name: str = Field( - ..., - description="The name of the proposal contract", - example="aibtc-treasury-withdraw-stx", - ) - proposal_args: Dict[str, str] = Field( - ..., - description="Arguments for the proposal in key-value format", - example={ - "stx_amount": "1000000", - "recipient_address": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", - }, - ) - generate_files: bool = Field( - False, - description="Whether to generate and save proposal files", - ) - - -class GenerateCoreProposalTool(BaseTool): - name: str = "dao_generate_core_proposal" - description: str = ( - "Generate a core proposal for the DAO. " - "This will create the proposal contract but not deploy it. " - "Returns the generated proposal details if successful." - ) - args_schema: Type[BaseModel] = GenerateCoreProposalInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to generate a core proposal.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - str(proposal_args).replace("'", '"'), # Convert Python dict to JSON string - str(generate_files).lower(), - ] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/core-proposals", - "generate-core-proposal.ts", - *args, - ) - - def _run( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to generate a core proposal.""" - return self._deploy( - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - proposal_args, - generate_files, - **kwargs, - ) - - async def _arun( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - proposal_args, - generate_files, - **kwargs, - ) - - -class DeployCoreProposalInput(BaseModel): - """Input schema for deploying a core proposal.""" - - dao_deployer_address: str = Field( - ..., - description="The address of the DAO deployer", - example="ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", - ) - dao_token_symbol: str = Field( - ..., - description="The token symbol for the DAO", - example="aibtc", - ) - proposal_contract_name: str = Field( - ..., - description="The name of the proposal contract", - example="aibtc-treasury-withdraw-stx", - ) - proposal_args: Dict[str, str] = Field( - ..., - description="Arguments for the proposal in key-value format", - example={ - "stx_amount": "1000000", - "recipient_address": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", - }, - ) - generate_files: bool = Field( - False, - description="Whether to generate and save proposal files", - ) - - -class DeployCoreProposalTool(BaseTool): - name: str = "dao_deploy_core_proposal" - description: str = ( - "Deploy a core proposal for the DAO. " - "This will generate and deploy the proposal contract. " - "This is a required step before proposing. " - "Returns the deployment details if successful." - ) - args_schema: Type[BaseModel] = DeployCoreProposalInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to deploy a core proposal.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - str(proposal_args).replace("'", '"'), # Convert Python dict to JSON string - str(generate_files).lower(), - ] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/core-proposals", - "deploy-core-proposal.ts", - *args, - ) - - def _run( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to deploy a core proposal.""" - return self._deploy( - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - proposal_args, - generate_files, - **kwargs, - ) - - async def _arun( - self, - dao_deployer_address: str, - dao_token_symbol: str, - proposal_contract_name: str, - proposal_args: Dict[str, str], - generate_files: bool = False, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy( - dao_deployer_address, - dao_token_symbol, - proposal_contract_name, - proposal_args, - generate_files, - **kwargs, - ) diff --git a/tools/dao_ext_onchain_messaging.py b/tools/dao_ext_onchain_messaging.py deleted file mode 100644 index 7bbb7219..00000000 --- a/tools/dao_ext_onchain_messaging.py +++ /dev/null @@ -1,73 +0,0 @@ -from typing import Any, Dict, Optional, Type -from uuid import UUID - -from langchain.tools import BaseTool -from pydantic import BaseModel, Field - -from tools.bun import BunScriptRunner - - -class SendMessageInput(BaseModel): - """Input schema for sending an onchain message.""" - - messaging_contract: str = Field( - ..., - description="Contract principal of the messaging contract for the DAO", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.dao-onchain-messaging", - ) - message: str = Field(..., description="Message to send") - - -class SendMessageTool(BaseTool): - name: str = "dao_messaging_send" - description: str = ( - "Send a message through the DAO's onchain messaging system. " - "Messages are stored permanently on the blockchain and can be viewed by anyone." - ) - args_schema: Type[BaseModel] = SendMessageInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - messaging_contract: str, - message: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to send a message.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [ - messaging_contract, - message, - ] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/onchain-messaging/public", - "send-message.ts", - *args, - ) - - def _run( - self, - messaging_contract: str, - message: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to send a message.""" - return self._deploy(messaging_contract, message, **kwargs) - - async def _arun( - self, - messaging_contract: str, - message: str, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(messaging_contract, message, **kwargs) diff --git a/tools/dao_ext_payments_invoices.py b/tools/dao_ext_payments_invoices.py deleted file mode 100644 index 919ecae3..00000000 --- a/tools/dao_ext_payments_invoices.py +++ /dev/null @@ -1,338 +0,0 @@ -from typing import Any, Dict, Optional, Type -from uuid import UUID - -from langchain.tools import BaseTool -from pydantic import BaseModel, Field - -from tools.bun import BunScriptRunner - - -class GetInvoiceInput(BaseModel): - """Input schema for getting invoice details.""" - - payments_invoices_contract: str = Field( - ..., - description="Contract principal of the payments and invoices contract", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-payments-invoices", - ) - invoice_index: int = Field(..., description="Index of the invoice to retrieve") - - -class GetInvoiceTool(BaseTool): - name: str = "dao_get_invoice" - description: str = ( - "Get details of a specific invoice from the DAO's payments and invoices system. " - "Returns the full invoice data if it exists." - ) - args_schema: Type[BaseModel] = GetInvoiceInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - payments_invoices_contract: str, - invoice_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get invoice details.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [payments_invoices_contract, str(invoice_index)] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/payments-invoices/read-only", - "get-invoice.ts", - *args, - ) - - def _run( - self, - payments_invoices_contract: str, - invoice_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get invoice details.""" - return self._deploy(payments_invoices_contract, invoice_index, **kwargs) - - async def _arun( - self, - payments_invoices_contract: str, - invoice_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(payments_invoices_contract, invoice_index, **kwargs) - - -class GetResourceInput(BaseModel): - """Input schema for getting resource details.""" - - payments_invoices_contract: str = Field( - ..., - description="Contract principal of the payments and invoices contract", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-payments-invoices", - ) - resource_index: int = Field(..., description="Index of the resource to retrieve") - - -class GetResourceTool(BaseTool): - name: str = "dao_get_resource" - description: str = ( - "Get details of a specific resource from the DAO's payments and invoices system. " - "Returns the full resource data if it exists." - ) - args_schema: Type[BaseModel] = GetResourceInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - payments_invoices_contract: str, - resource_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get resource details.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [payments_invoices_contract, str(resource_index)] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/payments-invoices/read-only", - "get-resource.ts", - *args, - ) - - def _run( - self, - payments_invoices_contract: str, - resource_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get resource details.""" - return self._deploy(payments_invoices_contract, resource_index, **kwargs) - - async def _arun( - self, - payments_invoices_contract: str, - resource_index: int, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(payments_invoices_contract, resource_index, **kwargs) - - -class GetResourceByNameInput(BaseModel): - """Input schema for getting resource details by name.""" - - payments_invoices_contract: str = Field( - ..., - description="Contract principal of the payments and invoices contract", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-payments-invoices", - ) - resource_name: str = Field(..., description="Name of the resource to retrieve") - - -class GetResourceByNameTool(BaseTool): - name: str = "dao_get_resource_by_name" - description: str = ( - "Get details of a specific resource by its name from the DAO's payments and invoices system. " - "Returns the full resource data if it exists." - ) - args_schema: Type[BaseModel] = GetResourceByNameInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - payments_invoices_contract: str, - resource_name: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get resource details by name.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [payments_invoices_contract, resource_name] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/payments-invoices/read-only", - "get-resource-by-name.ts", - *args, - ) - - def _run( - self, - payments_invoices_contract: str, - resource_name: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get resource details by name.""" - return self._deploy(payments_invoices_contract, resource_name, **kwargs) - - async def _arun( - self, - payments_invoices_contract: str, - resource_name: str, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(payments_invoices_contract, resource_name, **kwargs) - - -class PayInvoiceInput(BaseModel): - """Input schema for paying an invoice.""" - - payments_invoices_contract: str = Field( - ..., - description="Contract principal of the payments and invoices contract", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-payments-invoices", - ) - resource_index: int = Field(..., description="Index of the resource to pay for") - memo: Optional[str] = Field( - None, description="Optional memo to include with the payment" - ) - - -class PayInvoiceTool(BaseTool): - name: str = "dao_pay_invoice" - description: str = ( - "Pay an invoice for a specific resource in the DAO's payments and invoices system. " - "Optionally includes a memo with the payment." - ) - args_schema: Type[BaseModel] = PayInvoiceInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - payments_invoices_contract: str, - resource_index: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to pay an invoice.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [payments_invoices_contract, str(resource_index)] - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/payments-invoices/public", - "pay-invoice.ts", - *args, - ) - - def _run( - self, - payments_invoices_contract: str, - resource_index: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to pay an invoice.""" - return self._deploy(payments_invoices_contract, resource_index, memo, **kwargs) - - async def _arun( - self, - payments_invoices_contract: str, - resource_index: int, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(payments_invoices_contract, resource_index, memo, **kwargs) - - -class PayInvoiceByResourceNameInput(BaseModel): - """Input schema for paying an invoice by resource name.""" - - payments_invoices_contract: str = Field( - ..., - description="Contract principal of the payments and invoices contract", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-payments-invoices", - ) - resource_name: str = Field(..., description="Name of the resource to pay for") - memo: Optional[str] = Field( - None, description="Optional memo to include with the payment" - ) - - -class PayInvoiceByResourceNameTool(BaseTool): - name: str = "dao_pay_invoice_by_resource_name" - description: str = ( - "Pay an invoice for a specific resource by its name in the DAO's payments and invoices system. " - "Optionally includes a memo with the payment." - ) - args_schema: Type[BaseModel] = PayInvoiceByResourceNameInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - payments_invoices_contract: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to pay an invoice by resource name.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [payments_invoices_contract, resource_name] - if memo: - args.append(memo) - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/payments-invoices/public", - "pay-invoice-by-resource-name.ts", - *args, - ) - - def _run( - self, - payments_invoices_contract: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to pay an invoice by resource name.""" - return self._deploy(payments_invoices_contract, resource_name, memo, **kwargs) - - async def _arun( - self, - payments_invoices_contract: str, - resource_name: str, - memo: Optional[str] = None, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(payments_invoices_contract, resource_name, memo, **kwargs) diff --git a/tools/dao_ext_timed_vault.py b/tools/dao_ext_timed_vault.py deleted file mode 100644 index 60c44025..00000000 --- a/tools/dao_ext_timed_vault.py +++ /dev/null @@ -1,188 +0,0 @@ -from typing import Any, Dict, Optional, Type -from uuid import UUID - -from langchain.tools import BaseTool -from pydantic import BaseModel, Field - -from tools.bun import BunScriptRunner - - -class GetAccountTermsInput(BaseModel): - """Input schema for getting timed vault terms.""" - - timed_vault_contract: str = Field( - ..., - description="Contract principal of the timed vault", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-timed-vault", - ) - - -class GetAccountTermsTool(BaseTool): - name: str = "dao_timedvault_get_account_terms" - description: str = ( - "Get the current terms of the DAO's timed vault. " - "Returns information about withdrawal limits, periods, and account holder." - ) - args_schema: Type[BaseModel] = GetAccountTermsInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get account terms.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [timed_vault_contract] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/timed-vault/read-only", - "get-account-terms.ts", - *args, - ) - - def _run( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to get account terms.""" - return self._deploy(timed_vault_contract, **kwargs) - - async def _arun( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(timed_vault_contract, **kwargs) - - -class DepositSTXInput(BaseModel): - """Input schema for depositing STX.""" - - timed_vault_contract: str = Field( - ..., - description="Contract principal of the timed vault", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-timed-vault", - ) - amount: int = Field(..., description="Amount of STX to deposit in microstacks") - - -class DepositSTXTool(BaseTool): - name: str = "dao_timedvault_deposit_stx" - description: str = ( - "Deposit STX into the DAO's timed vault. " - "The amount should be specified in microstacks (1 STX = 1,000,000 microstacks)." - ) - args_schema: Type[BaseModel] = DepositSTXInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - timed_vault_contract: str, - amount: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to deposit STX.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [timed_vault_contract, str(amount)] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/timed-vault/public", - "deposit-stx.ts", - *args, - ) - - def _run( - self, - timed_vault_contract: str, - amount: int, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to deposit STX.""" - return self._deploy(timed_vault_contract, amount, **kwargs) - - async def _arun( - self, - timed_vault_contract: str, - amount: int, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(timed_vault_contract, amount, **kwargs) - - -class WithdrawSTXInput(BaseModel): - """Input schema for withdrawing STX.""" - - timed_vault_contract: str = Field( - ..., - description="Contract principal of the timed vault", - example="ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-timed-vault", - ) - - -class WithdrawSTXTool(BaseTool): - name: str = "dao_timedvault_withdraw_stx" - description: str = ( - "Withdraw STX from the DAO's timed vault. " - "This will withdraw the maximum allowed amount based on the account terms." - ) - args_schema: Type[BaseModel] = WithdrawSTXInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to withdraw STX.""" - if self.wallet_id is None: - return {"success": False, "message": "Wallet ID is required", "data": None} - - args = [timed_vault_contract] - - return BunScriptRunner.bun_run( - self.wallet_id, - "aibtc-dao/extensions/timed-vault/public", - "withdraw-stx.ts", - *args, - ) - - def _run( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Execute the tool to withdraw STX.""" - return self._deploy(timed_vault_contract, **kwargs) - - async def _arun( - self, - timed_vault_contract: str, - **kwargs, - ) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(timed_vault_contract, **kwargs) diff --git a/tools/tools_factory.py b/tools/tools_factory.py index b888915f..42c37640 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -19,13 +19,7 @@ GetTotalVotesTool, GetVotingConfigurationTool, GetVotingPowerTool, - ProposeActionAddResourceTool, - ProposeActionAllowAssetTool, ProposeActionSendMessageTool, - ProposeActionSetAccountHolderTool, - ProposeActionSetWithdrawalAmountTool, - ProposeActionSetWithdrawalPeriodTool, - ProposeActionToggleResourceTool, VoteOnActionProposalTool, ) from .dao_ext_charter import ( @@ -33,19 +27,6 @@ GetCurrentDaoCharterVersionTool, GetDaoCharterTool, ) -from .dao_ext_core_proposals import ( - DeployCoreProposalTool, - GenerateCoreProposalTool, -) -from .dao_ext_payments_invoices import ( - GetInvoiceTool, - GetResourceByNameTool, - GetResourceTool, - PayInvoiceByResourceNameTool, - PayInvoiceTool, -) -from .dao_ext_timed_vault import DepositSTXTool as TimedVaultDepositSTXTool -from .dao_ext_timed_vault import GetAccountTermsTool, WithdrawSTXTool from .dao_ext_treasury import GetAllowedAssetTool, IsAllowedAssetTool from .database import ( AddScheduledTaskTool, @@ -123,56 +104,8 @@ def initialize_tools( logger.warning(f"Failed to get wallet for agent {agent_id}: {e}") tools = { - "coinmarketcap_get_market_data": GetBitcoinData(), "bitflow_execute_trade": BitflowExecuteTradeTool(wallet_id), - "contracts_get_sip10_info": ContractSIP10InfoTool(wallet_id), - "contracts_deploy_dao": ContractDAODeployTool(wallet_id), "contracts_fetch_source_code": FetchContractSourceTool(wallet_id), - "dao_coreproposals_generate_proposal": GenerateCoreProposalTool(wallet_id), - "dao_coreproposals_deploy_proposal": DeployCoreProposalTool(wallet_id), - "dao_actionproposals_conclude_proposal": ConcludeActionProposalTool(wallet_id), - "dao_actionproposals_get_liquid_supply": GetLiquidSupplyTool(wallet_id), - "dao_actionproposals_get_proposal": GetProposalTool(wallet_id), - "dao_actionproposals_get_total_votes": GetTotalVotesTool(wallet_id), - "dao_actionproposals_get_voting_configuration": GetVotingConfigurationTool( - wallet_id - ), - "dao_actionproposals_get_voting_power": GetVotingPowerTool(wallet_id), - "dao_actionproposals_vote_on_proposal": VoteOnActionProposalTool(wallet_id), - "dao_actionproposals_propose_add_resource": ProposeActionAddResourceTool( - wallet_id - ), - "dao_actionproposals_propose_allow_asset": ProposeActionAllowAssetTool( - wallet_id - ), - "dao_actionproposals_propose_send_message": ProposeActionSendMessageTool( - wallet_id - ), - "dao_actionproposals_propose_set_account_holder": ProposeActionSetAccountHolderTool( - wallet_id - ), - "dao_actionproposals_propose_set_withdrawal_amount": ProposeActionSetWithdrawalAmountTool( - wallet_id - ), - "dao_actionproposals_propose_set_withdrawal_period": ProposeActionSetWithdrawalPeriodTool( - wallet_id - ), - "dao_actionproposals_propose_toggle_resource": ProposeActionToggleResourceTool( - wallet_id - ), - "dao_timedvault_get_account_terms": GetAccountTermsTool(wallet_id), - "dao_timedvault_deposit_stx": TimedVaultDepositSTXTool(wallet_id), - "dao_timedvault_withdraw_stx": WithdrawSTXTool(wallet_id), - "dao_charter_get_current": GetCurrentDaoCharterTool(wallet_id), - "dao_charter_get_current_version": GetCurrentDaoCharterVersionTool(wallet_id), - "dao_charter_get_version": GetDaoCharterTool(wallet_id), - "dao_payments_get_invoice": GetInvoiceTool(wallet_id), - "dao_payments_get_resource": GetResourceTool(wallet_id), - "dao_payments_get_resource_by_name": GetResourceByNameTool(wallet_id), - "dao_payments_pay_invoice": PayInvoiceTool(wallet_id), - "dao_payments_pay_invoice_by_resource": PayInvoiceByResourceNameTool(wallet_id), - "dao_treasury_get_allowed_asset": GetAllowedAssetTool(wallet_id), - "dao_treasury_is_allowed_asset": IsAllowedAssetTool(wallet_id), "database_add_scheduled_task": AddScheduledTaskTool(profile_id, agent_id), "database_get_dao_list": GetDAOListTool(), "database_get_dao_get_by_name": GetDAOByNameTool(), @@ -186,7 +119,6 @@ def initialize_tools( "lunarcrush_get_token_metrics": LunarCrushTokenMetricsTool(), "lunarcrush_search": SearchLunarCrushTool(), "lunarcrush_get_token_metadata": LunarCrushTokenMetadataTool(), - "stacks_get_transaction_status": StacksTransactionStatusTool(wallet_id), "stacks_get_transaction_details": StacksTransactionTool(wallet_id), "stacks_get_transactions_by_address": StacksTransactionByAddressTool(wallet_id), "stacks_get_contract_info": STXGetContractInfoTool(), From fcc45a79dabb12694be5691d83debf38591c6a98 Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:26:42 -0700 Subject: [PATCH 3/7] fix: remove simplified tx status endpoint Easier to pass the full JSON to the agent if it needs tx details, less confusion on which tool to use --- tools/tools_factory.py | 1 - tools/transactions.py | 51 ------------------------------------------ 2 files changed, 52 deletions(-) diff --git a/tools/tools_factory.py b/tools/tools_factory.py index 42c37640..b4bb100b 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -51,7 +51,6 @@ from .telegram import SendTelegramNotificationTool from .transactions import ( StacksTransactionByAddressTool, - StacksTransactionStatusTool, StacksTransactionTool, ) from .twitter import TwitterPostTweetTool diff --git a/tools/transactions.py b/tools/transactions.py index 431f798b..94ee8a75 100644 --- a/tools/transactions.py +++ b/tools/transactions.py @@ -7,57 +7,6 @@ from .bun import BunScriptRunner - -class StacksTransactionStatusInput(BaseModel): - """Input schema for checking Stacks transaction status.""" - - transaction_id: str = Field( - ..., description="The ID of the transaction to check the status for." - ) - - -class StacksTransactionStatusTool(BaseTool): - name: str = "stacks_transaction_status" - description: str = ( - "Get the current status of a Stacks blockchain transaction using its ID. " - "Returns success status and transaction details if available." - ) - args_schema: Type[BaseModel] = StacksTransactionStatusInput - return_direct: bool = False - wallet_id: Optional[UUID] = None - - def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): - super().__init__(**kwargs) - self.wallet_id = wallet_id - - def _deploy(self, transaction_id: str, **kwargs) -> Dict[str, Any]: - """Execute the tool to check transaction status.""" - if self.wallet_id is None: - return { - "success": False, - "error": "Wallet ID is required", - "output": "", - } - try: - result = BunScriptRunner.bun_run( - self.wallet_id, - "stacks-transactions", - "get-transaction-status.ts", - transaction_id, - ) - return result - except Exception as e: - return {"output": None, "error": str(e), "success": False} - - def _run(self, transaction_id: str, **kwargs) -> Dict[str, Any]: - """Execute the tool to check transaction status.""" - return self._deploy(transaction_id, **kwargs) - - async def _arun(self, transaction_id: str, **kwargs) -> Dict[str, Any]: - """Async version of the tool.""" - return self._deploy(transaction_id, **kwargs) - - class StacksTransactionInput(BaseModel): """Input schema for retrieving detailed Stacks transaction information.""" From ca75298c314fc35f8c1a7097bf29d89190a4ca97 Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:29:04 -0700 Subject: [PATCH 4/7] fix: add single tool back for dao charter We have it in the DB but allows us to look up any mission on-chain. --- tools/tools_factory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tools_factory.py b/tools/tools_factory.py index b4bb100b..c3b51fb9 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -24,8 +24,6 @@ ) from .dao_ext_charter import ( GetCurrentDaoCharterTool, - GetCurrentDaoCharterVersionTool, - GetDaoCharterTool, ) from .dao_ext_treasury import GetAllowedAssetTool, IsAllowedAssetTool from .database import ( @@ -103,8 +101,10 @@ def initialize_tools( logger.warning(f"Failed to get wallet for agent {agent_id}: {e}") tools = { + "bitflow_execute_trade": BitflowExecuteTradeTool(wallet_id), "contracts_fetch_source_code": FetchContractSourceTool(wallet_id), + "dao_charter_get_current_charter": GetCurrentDaoCharterTool(wallet_id), "database_add_scheduled_task": AddScheduledTaskTool(profile_id, agent_id), "database_get_dao_list": GetDAOListTool(), "database_get_dao_get_by_name": GetDAOByNameTool(), From 5ceb69b9290e05dc826b938148eb3234b2c0902d Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:29:59 -0700 Subject: [PATCH 5/7] fix: remove treasury tools, leave file to reuse later --- tools/tools_factory.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/tools_factory.py b/tools/tools_factory.py index c3b51fb9..dff043c1 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -25,7 +25,6 @@ from .dao_ext_charter import ( GetCurrentDaoCharterTool, ) -from .dao_ext_treasury import GetAllowedAssetTool, IsAllowedAssetTool from .database import ( AddScheduledTaskTool, DeleteScheduledTaskTool, From 0c0a45758806d94302a89b78c0d5064bb6499dd8 Mon Sep 17 00:00:00 2001 From: Jason Schrader Date: Thu, 29 May 2025 07:31:03 -0700 Subject: [PATCH 6/7] fix: some more cleanup --- tools/tools_factory.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/tools_factory.py b/tools/tools_factory.py index dff043c1..d20b6cfd 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -9,9 +9,7 @@ from .agent_account import AgentAccountDeployTool from .bitflow import BitflowExecuteTradeTool -from .coinmarketcap import GetBitcoinData from .contracts import ContractSIP10InfoTool, FetchContractSourceTool -from .dao_deployments import ContractDAODeployTool from .dao_ext_action_proposals import ( ConcludeActionProposalTool, GetLiquidSupplyTool, @@ -102,6 +100,7 @@ def initialize_tools( tools = { "bitflow_execute_trade": BitflowExecuteTradeTool(wallet_id), + "contracts_fetch_sip10_info": ContractSIP10InfoTool(wallet_id), "contracts_fetch_source_code": FetchContractSourceTool(wallet_id), "dao_charter_get_current_charter": GetCurrentDaoCharterTool(wallet_id), "database_add_scheduled_task": AddScheduledTaskTool(profile_id, agent_id), From e388d120387eefd2c7178777deaa01c48a0e660c Mon Sep 17 00:00:00 2001 From: "Jason Schrader (aider)" Date: Thu, 29 May 2025 10:33:09 -0700 Subject: [PATCH 7/7] feat: Update action proposal tools to match typescript versions --- tools/dao_ext_action_proposals.py | 428 ++++++++++++++++++++++++++---- tools/tools_factory.py | 18 +- 2 files changed, 393 insertions(+), 53 deletions(-) diff --git a/tools/dao_ext_action_proposals.py b/tools/dao_ext_action_proposals.py index f4417d6f..2b590bb1 100644 --- a/tools/dao_ext_action_proposals.py +++ b/tools/dao_ext_action_proposals.py @@ -364,7 +364,7 @@ def _deploy( return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/read-only", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", "get-liquid-supply.ts", *args, ) @@ -437,7 +437,7 @@ def _deploy( return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/read-only", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", "get-proposal.ts", *args, ) @@ -461,8 +461,72 @@ async def _arun( return self._deploy(action_proposals_voting_extension, proposal_id, **kwargs) -class GetTotalVotesInput(BaseModel): - """Input schema for getting total votes for a voter.""" +class GetVotingConfigurationInput(BaseModel): + """Input schema for getting voting configuration.""" + + action_proposals_voting_extension: str = Field( + ..., + description="Contract principal where the DAO creates action proposals for voting by DAO members.", + examples=[ + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", + ], + ) + + +class GetVotingConfigurationTool(BaseTool): + name: str = "dao_action_get_voting_configuration" + description: str = ( + "Get the voting configuration from the DAO action proposals contract. " + "Returns the current voting parameters and settings used for proposals." + ) + args_schema: Type[BaseModel] = GetVotingConfigurationInput + return_direct: bool = False + wallet_id: Optional[UUID] = None + + def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): + super().__init__(**kwargs) + self.wallet_id = wallet_id + + def _deploy( + self, + action_proposals_voting_extension: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get voting configuration.""" + if self.wallet_id is None: + return {"success": False, "message": "Wallet ID is required", "data": None} + + args = [ + action_proposals_voting_extension, + ] + + return BunScriptRunner.bun_run( + self.wallet_id, + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-voting-configuration.ts", + *args, + ) + + def _run( + self, + action_proposals_voting_extension: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get voting configuration.""" + return self._deploy(action_proposals_voting_extension, **kwargs) + + async def _arun( + self, + action_proposals_voting_extension: str, + **kwargs, + ) -> Dict[str, Any]: + """Async version of the tool.""" + return self._deploy(action_proposals_voting_extension, **kwargs) + + +class GetVotingPowerInput(BaseModel): + """Input schema for getting voting power.""" action_proposals_voting_extension: str = Field( ..., @@ -473,16 +537,20 @@ class GetTotalVotesInput(BaseModel): ], ) proposal_id: int = Field(..., description="ID of the proposal to check") - voter_address: str = Field(..., description="Address of the voter to check") + voter_address: str = Field( + ..., + description="Address of the voter to check voting power for", + examples=["ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18"], + ) -class GetTotalVotesTool(BaseTool): - name: str = "dao_action_get_total_votes" +class GetVotingPowerTool(BaseTool): + name: str = "dao_action_get_voting_power" description: str = ( - "Get the total votes cast by a specific voter on a proposal. " - "Returns the number of votes the voter has cast on the given proposal." + "Get the voting power of a specific address for a proposal. " + "Returns the number of votes the address can cast on the given proposal." ) - args_schema: Type[BaseModel] = GetTotalVotesInput + args_schema: Type[BaseModel] = GetVotingPowerInput return_direct: bool = False wallet_id: Optional[UUID] = None @@ -497,7 +565,7 @@ def _deploy( voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get total votes.""" + """Execute the tool to get voting power.""" if self.wallet_id is None: return {"success": False, "message": "Wallet ID is required", "data": None} @@ -509,8 +577,8 @@ def _deploy( return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/read-only", - "get-total-votes.ts", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-voting-power.ts", *args, ) @@ -521,28 +589,242 @@ def _run( voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get total votes.""" + """Execute the tool to get voting power.""" return self._deploy( action_proposals_voting_extension, proposal_id, voter_address, **kwargs ) + +class VetoActionProposalInput(BaseModel): + """Input schema for vetoing an action proposal.""" + + dao_action_proposal_voting_contract: str = Field( + ..., + description="Contract principal where the DAO creates action proposals for voting by DAO members.", + examples=[ + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", + ], + ) + proposal_id: int = Field(..., description="ID of the proposal to veto") + + +class VetoActionProposalTool(BaseTool): + name: str = "dao_action_veto_proposal" + description: str = ( + "Veto an existing action proposal in the DAO. " + "Allows casting a veto vote on a specific proposal ID " + "in the provided action proposals contract." + ) + args_schema: Type[BaseModel] = VetoActionProposalInput + return_direct: bool = False + wallet_id: Optional[UUID] = None + + def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): + super().__init__(**kwargs) + self.wallet_id = wallet_id + + def _deploy( + self, + dao_action_proposal_voting_contract: str, + proposal_id: int, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to veto an action proposal.""" + if self.wallet_id is None: + return {"success": False, "message": "Wallet ID is required", "data": None} + + args = [ + dao_action_proposal_voting_contract, + str(proposal_id), + ] + + return BunScriptRunner.bun_run( + self.wallet_id, + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/public", + "veto-action-proposal.ts", + *args, + ) + + def _run( + self, + dao_action_proposal_voting_contract: str, + proposal_id: int, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to veto an action proposal.""" + return self._deploy( + dao_action_proposal_voting_contract, proposal_id, **kwargs + ) + async def _arun( self, - action_proposals_voting_extension: str, + dao_action_proposal_voting_contract: str, + proposal_id: int, + **kwargs, + ) -> Dict[str, Any]: + """Async version of the tool.""" + return self._deploy( + dao_action_proposal_voting_contract, proposal_id, **kwargs + ) + + +class GetTotalProposalsInput(BaseModel): + """Input schema for getting total proposals data.""" + + dao_action_proposal_voting_contract: str = Field( + ..., + description="Contract principal where the DAO creates action proposals for voting by DAO members.", + examples=[ + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", + ], + ) + + +class GetTotalProposalsTool(BaseTool): + name: str = "dao_action_get_total_proposals" + description: str = ( + "Get the total proposals data from the DAO action proposals contract. " + "Returns counts of proposals and last proposal block information." + ) + args_schema: Type[BaseModel] = GetTotalProposalsInput + return_direct: bool = False + wallet_id: Optional[UUID] = None + + def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): + super().__init__(**kwargs) + self.wallet_id = wallet_id + + def _deploy( + self, + dao_action_proposal_voting_contract: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get total proposals data.""" + if self.wallet_id is None: + return {"success": False, "message": "Wallet ID is required", "data": None} + + args = [ + dao_action_proposal_voting_contract, + ] + + return BunScriptRunner.bun_run( + self.wallet_id, + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-total-proposals.ts", + *args, + ) + + def _run( + self, + dao_action_proposal_voting_contract: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get total proposals data.""" + return self._deploy(dao_action_proposal_voting_contract, **kwargs) + + async def _arun( + self, + dao_action_proposal_voting_contract: str, + **kwargs, + ) -> Dict[str, Any]: + """Async version of the tool.""" + return self._deploy(dao_action_proposal_voting_contract, **kwargs) + + +class GetVetoVoteRecordInput(BaseModel): + """Input schema for getting a veto vote record.""" + + dao_action_proposal_voting_contract: str = Field( + ..., + description="Contract principal where the DAO creates action proposals for voting by DAO members.", + examples=[ + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.faces-action-proposals-v2", + "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", + ], + ) + proposal_id: int = Field(..., description="ID of the proposal to check") + voter_address: str = Field( + ..., + description="Address of the voter to check the veto vote record for", + examples=["ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18"], + ) + + +class GetVetoVoteRecordTool(BaseTool): + name: str = "dao_action_get_veto_vote_record" + description: str = ( + "Get the veto vote record for a specific voter on a proposal. " + "Returns the amount of veto votes if a record exists, otherwise null." + ) + args_schema: Type[BaseModel] = GetVetoVoteRecordInput + return_direct: bool = False + wallet_id: Optional[UUID] = None + + def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): + super().__init__(**kwargs) + self.wallet_id = wallet_id + + def _deploy( + self, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get a veto vote record.""" + if self.wallet_id is None: + return {"success": False, "message": "Wallet ID is required", "data": None} + + args = [ + dao_action_proposal_voting_contract, + str(proposal_id), + voter_address, + ] + + return BunScriptRunner.bun_run( + self.wallet_id, + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-veto-vote-record.ts", + *args, + ) + + def _run( + self, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, + **kwargs, + ) -> Dict[str, Any]: + """Execute the tool to get a veto vote record.""" + return self._deploy( + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, + ) + + async def _arun( + self, + dao_action_proposal_voting_contract: str, proposal_id: int, voter_address: str, **kwargs, ) -> Dict[str, Any]: """Async version of the tool.""" return self._deploy( - action_proposals_voting_extension, proposal_id, voter_address, **kwargs + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, ) -class GetVotingConfigurationInput(BaseModel): - """Input schema for getting voting configuration.""" +class GetVoteRecordInput(BaseModel): + """Input schema for getting a vote record.""" - action_proposals_voting_extension: str = Field( + dao_action_proposal_voting_contract: str = Field( ..., description="Contract principal where the DAO creates action proposals for voting by DAO members.", examples=[ @@ -550,15 +832,21 @@ class GetVotingConfigurationInput(BaseModel): "ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18.t3st-action-proposals-v2", ], ) + proposal_id: int = Field(..., description="ID of the proposal to check") + voter_address: str = Field( + ..., + description="Address of the voter to check the vote record for", + examples=["ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18"], + ) -class GetVotingConfigurationTool(BaseTool): - name: str = "dao_action_get_voting_configuration" +class GetVoteRecordTool(BaseTool): + name: str = "dao_action_get_vote_record" description: str = ( - "Get the voting configuration from the DAO action proposals contract. " - "Returns the current voting parameters and settings used for proposals." + "Get the vote record for a specific voter on a proposal. " + "Returns the vote (true/false) and amount if a record exists, otherwise null." ) - args_schema: Type[BaseModel] = GetVotingConfigurationInput + args_schema: Type[BaseModel] = GetVoteRecordInput return_direct: bool = False wallet_id: Optional[UUID] = None @@ -568,46 +856,63 @@ def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): def _deploy( self, - action_proposals_voting_extension: str, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get voting configuration.""" + """Execute the tool to get a vote record.""" if self.wallet_id is None: return {"success": False, "message": "Wallet ID is required", "data": None} args = [ - action_proposals_voting_extension, + dao_action_proposal_voting_contract, + str(proposal_id), + voter_address, ] return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/read-only", - "get-voting-configuration.ts", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-vote-record.ts", *args, ) def _run( self, - action_proposals_voting_extension: str, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get voting configuration.""" - return self._deploy(action_proposals_voting_extension, **kwargs) + """Execute the tool to get a vote record.""" + return self._deploy( + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, + ) async def _arun( self, - action_proposals_voting_extension: str, - dao_token_contract_address: str, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, **kwargs, ) -> Dict[str, Any]: """Async version of the tool.""" - return self._deploy(action_proposals_voting_extension, **kwargs) + return self._deploy( + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, + ) -class GetVotingPowerInput(BaseModel): - """Input schema for getting voting power.""" +class GetVoteRecordsInput(BaseModel): + """Input schema for getting vote records (vote and veto vote).""" - action_proposals_voting_extension: str = Field( + dao_action_proposal_voting_contract: str = Field( ..., description="Contract principal where the DAO creates action proposals for voting by DAO members.", examples=[ @@ -618,18 +923,19 @@ class GetVotingPowerInput(BaseModel): proposal_id: int = Field(..., description="ID of the proposal to check") voter_address: str = Field( ..., - description="Address of the voter to check voting power for", + description="Address of the voter to check vote records for", examples=["ST3YT0XW92E6T2FE59B2G5N2WNNFSBZ6MZKQS5D18"], ) -class GetVotingPowerTool(BaseTool): - name: str = "dao_action_get_voting_power" +class GetVoteRecordsTool(BaseTool): + name: str = "dao_action_get_vote_records" description: str = ( - "Get the voting power of a specific address for a proposal. " - "Returns the number of votes the address can cast on the given proposal." + "Get both the regular vote record and veto vote record for a specific voter on a proposal. " + "Returns an object containing 'voteRecord' (vote and amount, or null) and " + "'vetoVoteRecord' (amount, or null)." ) - args_schema: Type[BaseModel] = GetVotingPowerInput + args_schema: Type[BaseModel] = GetVoteRecordsInput return_direct: bool = False wallet_id: Optional[UUID] = None @@ -639,38 +945,56 @@ def __init__(self, wallet_id: Optional[UUID] = None, **kwargs): def _deploy( self, - action_proposals_voting_extension: str, + dao_action_proposal_voting_contract: str, proposal_id: int, voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get voting power.""" + """Execute the tool to get vote records.""" if self.wallet_id is None: return {"success": False, "message": "Wallet ID is required", "data": None} args = [ - action_proposals_voting_extension, + dao_action_proposal_voting_contract, str(proposal_id), voter_address, ] return BunScriptRunner.bun_run( self.wallet_id, - "aibtc-dao/extensions/action-proposals/read-only", - "get-voting-power.ts", + "aibtc-cohort-0/dao-tools/extensions/action-proposal-voting/read-only", + "get-vote-records.ts", *args, ) def _run( self, - action_proposals_voting_extension: str, + dao_action_proposal_voting_contract: str, proposal_id: int, voter_address: str, **kwargs, ) -> Dict[str, Any]: - """Execute the tool to get voting power.""" + """Execute the tool to get vote records.""" return self._deploy( - action_proposals_voting_extension, proposal_id, voter_address, **kwargs + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, + ) + + async def _arun( + self, + dao_action_proposal_voting_contract: str, + proposal_id: int, + voter_address: str, + **kwargs, + ) -> Dict[str, Any]: + """Async version of the tool.""" + return self._deploy( + dao_action_proposal_voting_contract, + proposal_id, + voter_address, + **kwargs, ) async def _arun( diff --git a/tools/tools_factory.py b/tools/tools_factory.py index d20b6cfd..7125d2f7 100644 --- a/tools/tools_factory.py +++ b/tools/tools_factory.py @@ -14,10 +14,14 @@ ConcludeActionProposalTool, GetLiquidSupplyTool, GetProposalTool, - GetTotalVotesTool, + GetTotalProposalsTool, + GetVoteRecordTool, + GetVoteRecordsTool, + GetVetoVoteRecordTool, GetVotingConfigurationTool, GetVotingPowerTool, ProposeActionSendMessageTool, + VetoActionProposalTool, VoteOnActionProposalTool, ) from .dao_ext_charter import ( @@ -102,7 +106,19 @@ def initialize_tools( "bitflow_execute_trade": BitflowExecuteTradeTool(wallet_id), "contracts_fetch_sip10_info": ContractSIP10InfoTool(wallet_id), "contracts_fetch_source_code": FetchContractSourceTool(wallet_id), + "dao_action_conclude_proposal": ConcludeActionProposalTool(wallet_id), + "dao_action_get_liquid_supply": GetLiquidSupplyTool(wallet_id), + "dao_action_get_proposal": GetProposalTool(wallet_id), + "dao_action_get_total_proposals": GetTotalProposalsTool(wallet_id), + "dao_action_get_veto_vote_record": GetVetoVoteRecordTool(wallet_id), + "dao_action_get_vote_record": GetVoteRecordTool(wallet_id), + "dao_action_get_vote_records": GetVoteRecordsTool(wallet_id), + "dao_action_get_voting_configuration": GetVotingConfigurationTool(wallet_id), + "dao_action_get_voting_power": GetVotingPowerTool(wallet_id), + "dao_action_veto_proposal": VetoActionProposalTool(wallet_id), + "dao_action_vote_on_proposal": VoteOnActionProposalTool(wallet_id), "dao_charter_get_current_charter": GetCurrentDaoCharterTool(wallet_id), + "dao_propose_action_send_message": ProposeActionSendMessageTool(wallet_id), "database_add_scheduled_task": AddScheduledTaskTool(profile_id, agent_id), "database_get_dao_list": GetDAOListTool(), "database_get_dao_get_by_name": GetDAOByNameTool(),