Skip to content

Commit fd669c5

Browse files
authored
feat: Add Hip1261 Implementation (#2231)
Signed-off-by: aceppaluni <aceppaluni@gmail.com>
1 parent 93846f0 commit fd669c5

11 files changed

Lines changed: 831 additions & 4 deletions

File tree

src/hiero_sdk_python/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
# Errors
4949
from .exceptions import PrecheckError, ReceiptStatusError
5050

51+
# Fee
52+
from .fees.fee_estimate import FeeEstimate
53+
from .fees.fee_estimate_mode import FeeEstimateMode
54+
from .fees.fee_estimate_response import FeeEstimateResponse
55+
from .fees.fee_extra import FeeExtra
56+
from .fees.network_fee import NetworkFee
57+
5158
# File
5259
from .file.file_append_transaction import FileAppendTransaction
5360
from .file.file_contents_query import FileContentsQuery
@@ -77,6 +84,7 @@
7784
# Queries
7885
from .query.account_balance_query import CryptoGetAccountBalanceQuery
7986
from .query.account_info_query import AccountInfoQuery
87+
from .query.fee_estimate_query import FeeEstimateQuery
8088
from .query.token_info_query import TokenInfoQuery
8189
from .query.token_nft_info_query import TokenNftInfoQuery
8290
from .query.topic_info_query import TopicInfoQuery
@@ -227,6 +235,7 @@
227235
"TopicDeleteTransaction",
228236
"TopicId",
229237
# Queries
238+
"FeeEstimateQuery",
230239
"TopicInfoQuery",
231240
"TopicMessageQuery",
232241
"TransactionGetReceiptQuery",
@@ -257,6 +266,12 @@
257266
"FileContentsQuery",
258267
"FileUpdateTransaction",
259268
"FileDeleteTransaction",
269+
# Fee
270+
"FeeEstimateMode",
271+
"FeeEstimate",
272+
"FeeEstimateResponse",
273+
"FeeExtra",
274+
"NetworkFee",
260275
# Contract
261276
"ContractCreateTransaction",
262277
"ContractCallQuery",

src/hiero_sdk_python/consensus/topic_message_submit_transaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self.chunk_size: int = chunk_size or 1024
5050
self.max_chunks: int = max_chunks or 20
5151

52-
self._current_index = 0
52+
self._current_chunk_index = 0
5353
self._total_chunks = self.get_required_chunks()
5454
self._initial_transaction_id: TransactionId | None = None
5555
self._transaction_ids: list[TransactionId] = []
@@ -192,7 +192,7 @@ def _build_proto_body(self) -> consensus_submit_message_pb2.ConsensusSubmitMessa
192192

193193
content = self.message.encode("utf-8")
194194

195-
start_index = self._current_index * self.chunk_size
195+
start_index = self._current_chunk_index * self.chunk_size
196196
end_index = min(start_index + self.chunk_size, len(content))
197197
chunk_content = content[start_index:end_index]
198198

@@ -206,7 +206,7 @@ def _build_proto_body(self) -> consensus_submit_message_pb2.ConsensusSubmitMessa
206206
consensus_submit_message_pb2.ConsensusMessageChunkInfo(
207207
initialTransactionID=self._initial_transaction_id._to_proto(),
208208
total=self._total_chunks,
209-
number=self._current_index + 1,
209+
number=self._current_chunk_index + 1,
210210
)
211211
)
212212

@@ -371,7 +371,7 @@ def execute_all(
371371
responses = []
372372

373373
for chunk_index in range(self.get_required_chunks()):
374-
self._current_index = chunk_index
374+
self._current_chunk_index = chunk_index
375375

376376
if self._transaction_ids and chunk_index < len(self._transaction_ids):
377377
self.transaction_id = self._transaction_ids[chunk_index]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Fee estimation models for calculating base and extra fees.
2+
3+
This module defines the FeeEstimate dataclass, which aggregates
4+
a base fee with optional extra fee components.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from dataclasses import dataclass, field
10+
11+
from hiero_sdk_python.fees.fee_extra import FeeExtra
12+
13+
14+
@dataclass(frozen=True)
15+
class FeeEstimate:
16+
"""Represents a fee estimate composed of a base amount and optional extras."""
17+
18+
base: int
19+
extras: list[FeeExtra] = field(default_factory=list)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Enumeration of fee estimation modes.
2+
3+
Defines the available strategies for calculating fee estimates.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
from enum import Enum
9+
10+
11+
class FeeEstimateMode(str, Enum):
12+
"""Supported modes for fee estimation."""
13+
14+
STATE = "STATE"
15+
INTRINSIC = "INTRINSIC"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Response model for fee estimation results.
2+
3+
Contains the calculated fees across different categories along with
4+
the estimation mode and optional notes.
5+
"""
6+
7+
from __future__ import annotations
8+
9+
from dataclasses import dataclass
10+
11+
from hiero_sdk_python.fees.fee_estimate import FeeEstimate
12+
from hiero_sdk_python.fees.fee_estimate_mode import FeeEstimateMode
13+
from hiero_sdk_python.fees.network_fee import NetworkFee
14+
15+
16+
@dataclass(frozen=True)
17+
class FeeEstimateResponse:
18+
"""Represents the result of a fee estimation operation."""
19+
20+
mode: FeeEstimateMode
21+
network_fee: NetworkFee | None = None
22+
node_fee: FeeEstimate | None = None
23+
service_fee: FeeEstimate | None = None
24+
total: int = 0
25+
high_volume_multiplier: int = 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import annotations
2+
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass(frozen=True)
7+
class FeeExtra:
8+
"""
9+
Represents additional fee details associated with a transaction or operation.
10+
"""
11+
12+
name: str | None = None
13+
included: int | None = None
14+
count: int | None = None
15+
charged: int | None = None
16+
fee_per_unit: int | None = None
17+
subtotal: int | None = None
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import annotations
2+
3+
from dataclasses import dataclass
4+
5+
6+
@dataclass(frozen=True)
7+
class NetworkFee:
8+
multiplier: int
9+
subtotal: int

0 commit comments

Comments
 (0)