Skip to content

Commit f7ef21d

Browse files
chore: bump hak package version (#176)
Signed-off-by: skurzyp-blockydevs <stanislaw.kurzyp@blockydevs.com>
1 parent 20d65ec commit f7ef21d

File tree

12 files changed

+415
-130
lines changed

12 files changed

+415
-130
lines changed

python/hedera_agent_kit/mcp/toolkit.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
from typing import Any, List
1+
from typing import Any
22
from mcp.server.fastmcp import FastMCP
33
from hiero_sdk_python import Client
44
from hedera_agent_kit.shared.api import HederaAgentAPI
55
from hedera_agent_kit.shared.configuration import Configuration
66
from hedera_agent_kit.shared.tool_discovery import ToolDiscovery
77

8+
89
class HederaMCPToolkit:
910
def __init__(self, client: Client, configuration: Configuration):
1011
self.server = FastMCP("Hedera Agent Kit", dependencies=["hedera-agent-kit"])
11-
12+
1213
context = configuration.context
1314
tool_discovery = ToolDiscovery.create_from_configuration(configuration)
1415
all_tools = tool_discovery.get_all_tools(context, configuration)
@@ -21,7 +22,11 @@ def _register_tool(self, tool):
2122
@self.server.tool(name=tool.method, description=tool.description)
2223
async def handler(**kwargs: Any) -> str:
2324
params = kwargs
24-
if "kwargs" in kwargs and len(kwargs) == 1 and isinstance(kwargs["kwargs"], dict):
25+
if (
26+
"kwargs" in kwargs
27+
and len(kwargs) == 1
28+
and isinstance(kwargs["kwargs"], dict)
29+
):
2530
params = kwargs["kwargs"]
2631
result = await self._hedera_agent_kit.run(tool.method, params)
2732
return str(result)

python/hedera_agent_kit/plugins/core_consensus_query_plugin/get_topic_messages_query.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ def get_topic_messages_query_prompt(context: Context = {}) -> str:
4242
context_snippet: str = PromptGenerator.get_context_snippet(context)
4343
usage_instructions: str = PromptGenerator.get_parameter_usage_instructions()
4444

45-
return f"""
46-
{context_snippet}
45+
return f"""
46+
{context_snippet}
4747
48-
This tool will return the messages for a given Hedera topic.
48+
This tool will return the messages for a given Hedera topic.
4949
50-
Parameters:
51-
- topic_id (str, required): The topic ID to query
52-
- start_time (datetime, optional): The start datetime to query. If set, the messages will be returned after this datetime
53-
- end_time (datetime, optional): The end datetime to query. If set, the messages will be returned before this datetime
50+
Parameters:
51+
- topic_id (str, required): The topic ID to query
52+
- start_time (datetime, optional): The start datetime to query. If set, the messages will be returned after this datetime
53+
- end_time (datetime, optional): The end datetime to query. If set, the messages will be returned before this datetime
5454
- limit: (Optional) Max number of messages to return. Defaults to 100. Max value is 100.
55-
{usage_instructions}
55+
{usage_instructions}
5656
5757
Note: When limit is set, the most recent messages up to the limit will be returned within the specified time range.
5858
"""
@@ -73,16 +73,15 @@ def post_process(messages: List[Dict[str, Any]], topic_id: str) -> str:
7373
for message in messages:
7474
content = message.get("message", "")
7575
consensus_timestamp = message.get("consensus_timestamp", "N/A")
76-
messages_text_list.append(
77-
f"{content} - posted at: {consensus_timestamp}\n"
78-
)
76+
messages_text_list.append(f"{content} - posted at: {consensus_timestamp}\n")
7977

8078
messages_text = "".join(messages_text_list)
8179

82-
return f"""Messages for topic {topic_id}:
83-
--- Messages --- {messages_text}
80+
return f"""Messages for topic {topic_id}:
81+
--- Messages --- {messages_text}
8482
"""
8583

84+
8685
async def get_topic_messages_query(
8786
client: Client,
8887
context: Context,

python/hedera_agent_kit/shared/hedera_utils/mirrornode/hedera_mirrornode_decoders.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Mirrornode message decoding utilities."""
22

33
import base64
4-
from typing import List, Any, Dict, Union
4+
from typing import List, Any, Dict
55

66
from .types import TopicMessage
77

88

9-
def decode_base64_messages(
10-
messages: List[TopicMessage]
11-
) -> List[Dict[str, Any]]:
9+
def decode_base64_messages(messages: List[TopicMessage]) -> List[Dict[str, Any]]:
1210
"""Decode base64 message content to UTF-8 human-readable strings.
1311
1412
Args:

python/hedera_agent_kit/shared/hedera_utils/mirrornode/hedera_mirrornode_service_default_impl.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import base64
32
from decimal import Decimal
43
from typing import Optional, Any, Dict, List, Coroutine
54

@@ -134,12 +133,11 @@ async def get_topic_messages(
134133
if query_params.get("upperTimestamp")
135134
else ""
136135
)
137-
136+
138137
limit = query_params.get("limit", 100)
139-
encoding = query_params.get("encoding", "base64")
140138
# Request at most 100 messages per page (Mirror Node max)
141139
page_limit = min(limit, 100)
142-
140+
143141
url: str = (
144142
f"{self.base_url}/topics/{query_params['topic_id']}/messages?{lower}{upper}&order=desc&limit={page_limit}"
145143
)
@@ -154,9 +152,9 @@ async def get_topic_messages(
154152
batch = data.get("messages", [])
155153
if not batch:
156154
break
157-
155+
158156
messages.extend(batch)
159-
157+
160158
# effective_limit cancellation
161159
if len(messages) >= limit:
162160
break

python/hedera_agent_kit/shared/hedera_utils/mirrornode/hedera_mirrornode_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ def get_mirrornode_service(
2323
if mirrornode_service is not None:
2424
return mirrornode_service
2525
return HederaMirrornodeServiceDefaultImpl(ledger_id)
26-

python/hedera_agent_kit/shared/parameter_schemas/token_schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class NftTransfer(BaseModelWithArbitraryTypes):
151151

152152
class TransferNonFungibleTokenParameters(OptionalScheduledTransactionParams):
153153
source_account_id: Annotated[
154-
Optional[str], Field(description="Account ID of the token owner (defaults to operator).")
154+
Optional[str],
155+
Field(description="Account ID of the token owner (defaults to operator)."),
155156
] = None
156157
token_id: Annotated[str, Field(description="The NFT token ID.")]
157158
recipients: Annotated[

python/hedera_agent_kit/shared/strategies/tx_mode_strategy.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
from __future__ import annotations
99

1010
from abc import ABC, abstractmethod
11-
from typing import Any, Callable, Optional, cast
11+
from typing import Any, Callable, Optional
1212

1313
from hiero_sdk_python import (
1414
Client,
1515
TransactionReceipt,
16-
ResponseCode, TopicDeleteTransaction,
16+
ResponseCode,
1717
)
1818
from hiero_sdk_python.hapi.services.response_code_pb2 import ResponseCodeEnum
1919
from hiero_sdk_python.transaction.transaction import Transaction
@@ -101,10 +101,13 @@ async def handle(
101101
# Create a raw response object
102102
raw_transaction_response = RawTransactionResponse(
103103
status=ResponseCode(receipt.status).name,
104-
account_id=getattr(receipt, "account_id", None) or getattr(tx, "account_id", None),
105-
token_id=getattr(receipt, "token_id", None) or getattr(tx, "token_id", None),
104+
account_id=getattr(receipt, "account_id", None)
105+
or getattr(tx, "account_id", None),
106+
token_id=getattr(receipt, "token_id", None)
107+
or getattr(tx, "token_id", None),
106108
transaction_id=getattr(receipt, "transaction_id", None),
107-
topic_id=getattr(receipt, "topic_id", None) or getattr(tx, "topic_id", None),
109+
topic_id=getattr(receipt, "topic_id", None)
110+
or getattr(tx, "topic_id", None),
108111
schedule_id=getattr(receipt, "schedule_id", None),
109112
factory_contract_id=None,
110113
# In the case of tools like create_erc20 or create_er721, the sdk returns the id of factory contract.

0 commit comments

Comments
 (0)