Skip to content

Commit

Permalink
chore: bump to 0.1.3 and return values
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMinarsch committed May 30, 2023
1 parent a466b9a commit 387bda9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mech_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"
18 changes: 12 additions & 6 deletions mech_client/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import sys
import time
import warnings
from typing import Optional
from typing import Any, Dict, Optional

import requests
import websocket
Expand All @@ -55,7 +55,7 @@
)
WSS_ENDPOINT = os.getenv(
"WEBSOCKET_ENDPOINT",
"wss://gno.getblock.io/3042bb06-d18e-4ce0-8ccf-83eedd35532b/mainnet/",
"wss://rpc.eu-central-2.gateway.fm/ws/v4/gnosis/non-archival/mainnet",
)

# Ignore a specific warning message
Expand Down Expand Up @@ -164,9 +164,10 @@ def watch_for_events(
contract_instance: Contract,
ethereum_ledger_api: EthereumApi,
ethereum_crypto: EthereumCrypto,
) -> None:
) -> Dict[str, Any]:
"""Watches for events on mech."""
is_waiting = True
request_id = None
while is_waiting:
msg = wss.recv()
data = json.loads(msg)
Expand Down Expand Up @@ -195,13 +196,18 @@ def watch_for_events(
print(f"Data arrived: {data_url}")
is_waiting = False
response = requests.get(data_url + "/" + str(request_id))
result = response.json()["result"]
response_json = response.json()
result = response_json["result"]
print(f"Data:\n{result}")
return response_json


def interact(prompt: str, tool: str) -> None:
def interact(prompt: str, tool: str) -> Dict[str, Any]:
ethereum_crypto = EthereumCrypto(private_key_path=PRIVATE_KEY_FILE_PATH)
ethereum_ledger_api = EthereumApi(**ETHEREUM_TESTNET_CONFIG)
wss = register_event_handlers(ethereum_crypto)
contract_instance = send_request(ethereum_crypto, ethereum_ledger_api, prompt, tool)
watch_for_events(wss, contract_instance, ethereum_ledger_api, ethereum_crypto)
response = watch_for_events(
wss, contract_instance, ethereum_ledger_api, ethereum_crypto
)
return response
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mech-client"
version = "0.1.3"
version = "0.1.4"
description = "Basic client to interact with a mech"
authors = ["David Minarsch <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 387bda9

Please sign in to comment.