Skip to content

Commit

Permalink
Receive + send working
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfior committed Dec 27, 2024
1 parent f8e1331 commit 1a8adb6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion prediction_market_agent/agents/microchain_agent/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def run_general_agent(
initial_formatted_system_prompt = agent.system_prompt

iteration = 0
while self.max_iterations is None or iteration < self.max_iterations:
while not agent.do_stop and (
self.max_iterations is None or iteration < self.max_iterations
):
starting_history_length = len(agent.history)
try:
# After the first iteration, resume=True to not re-initialize the agent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from prediction_market_agent_tooling.loggers import logger
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
from web3 import Web3

from prediction_market_agent.agents.microchain_agent.microchain_agent_keys import (
MicrochainAgentKeys,
Expand Down Expand Up @@ -51,6 +52,7 @@ def __call__(self, address: str, message: str, fee: float) -> str:
api_keys = APIKeys_PMAT(BET_FROM_PRIVATE_KEY=keys.bet_from_private_key)
send_message(
api_keys=api_keys,
recipient=Web3.to_checksum_address(address),
message=HexBytes(compress_message(message)),
amount_wei=xdai_to_wei(keys.cap_sending_xdai(xdai_type(fee))),
)
Expand Down
7 changes: 5 additions & 2 deletions prediction_market_agent/db/agent_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ def pop_message(api_keys: APIKeys_PMAT) -> MessageContainer:


def send_message(
api_keys: APIKeys_PMAT, message: HexBytes, amount_wei: Wei
api_keys: APIKeys_PMAT,
recipient: ChecksumAddress,
message: HexBytes,
amount_wei: Wei,
) -> TxReceipt:
agent_comm_contract = AgentCommunicationContract()
return agent_comm_contract.send_message(
api_keys=api_keys,
agent_address=api_keys.bet_from_address,
agent_address=recipient,
message=message,
amount_wei=amount_wei,
web3=ContractOnGnosisChain.get_web3(),
Expand Down

0 comments on commit 1a8adb6

Please sign in to comment.