|
8 | 8 | from hiero_sdk_python.schedule.schedule_create_transaction import ScheduleCreateTransaction |
9 | 9 | from hiero_sdk_python.schedule.schedule_delete_transaction import ScheduleDeleteTransaction |
10 | 10 | from hiero_sdk_python.schedule.schedule_id import ScheduleId |
| 11 | +from hiero_sdk_python.schedule.schedule_sign_transaction import ScheduleSignTransaction |
11 | 12 | from hiero_sdk_python.timestamp import Timestamp |
12 | 13 | from hiero_sdk_python.transaction.transaction import Transaction |
13 | 14 | from hiero_sdk_python.transaction.transaction_receipt import TransactionReceipt |
|
22 | 23 | from tck.param.allowance import ApproveAllowanceParams |
23 | 24 | from tck.param.base import BaseTransactionParams |
24 | 25 | from tck.param.common import CommonTransactionParams |
25 | | -from tck.param.schedule import CreateScheduleParams, DeleteScheduleParams, ScheduledTransactionParams |
| 26 | +from tck.param.schedule import ( |
| 27 | + CreateScheduleParams, |
| 28 | + DeleteScheduleParams, |
| 29 | + ScheduledTransactionParams, |
| 30 | + SignScheduleParams, |
| 31 | +) |
26 | 32 | from tck.param.token import BurnTokenParams, MintTokenParams |
27 | 33 | from tck.param.topic import CreateTopicParams, TopicMessageSubmitParams |
28 | 34 | from tck.param.transfer import TransferCryptoParams |
29 | | -from tck.response.schedule import CreateScheduleResponse, DeleteScheduleResponse |
| 35 | +from tck.response.schedule import CreateScheduleResponse, DeleteScheduleResponse, SignScheduleResponse |
30 | 36 | from tck.util.client_utils import get_client |
31 | 37 | from tck.util.constants import DEFAULT_GRPC_TIMEOUT |
32 | 38 | from tck.util.key_utils import get_key_from_string |
@@ -118,6 +124,16 @@ def _build_create_schedule_transaction(params: CreateScheduleParams) -> Schedule |
118 | 124 | return transaction |
119 | 125 |
|
120 | 126 |
|
| 127 | +def _build_sign_schedule_transaction(params: SignScheduleParams) -> ScheduleSignTransaction: |
| 128 | + """Build a ScheduleSignTransaction from TCK params.""" |
| 129 | + transaction = ScheduleSignTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
| 130 | + |
| 131 | + if params.scheduleId is not None: |
| 132 | + transaction.set_schedule_id(ScheduleId.from_string(params.scheduleId)) |
| 133 | + |
| 134 | + return transaction |
| 135 | + |
| 136 | + |
121 | 137 | def _build_delete_schedule_transaction(params: DeleteScheduleParams) -> ScheduleDeleteTransaction: |
122 | 138 | """Builds a ScheduleDeleteTransaction from the provided parameters.""" |
123 | 139 | transaction = ScheduleDeleteTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT) |
@@ -152,6 +168,32 @@ def create_schedule(params: CreateScheduleParams) -> CreateScheduleResponse: |
152 | 168 | return CreateScheduleResponse(schedule_id, scheduled_transaction_id, ResponseCode(receipt.status).name) |
153 | 169 |
|
154 | 170 |
|
| 171 | +@rpc_method("signSchedule") |
| 172 | +def sign_schedule(params: SignScheduleParams) -> SignScheduleResponse: |
| 173 | + """Sign a schedule.""" |
| 174 | + common_params = params.commonTransactionParams |
| 175 | + if ( |
| 176 | + common_params is not None |
| 177 | + and common_params.maxTransactionFee is not None |
| 178 | + and common_params.maxTransactionFee < 0 |
| 179 | + ): |
| 180 | + # Protobuf transactionFee is unsigned, so a negative TCK boundary value |
| 181 | + # cannot reach network precheck in this SDK. |
| 182 | + raise JsonRpcError.hiero_error({"status": ResponseCode.INSUFFICIENT_TX_FEE.name}) |
| 183 | + |
| 184 | + client = get_client(params.sessionId) |
| 185 | + |
| 186 | + transaction = _build_sign_schedule_transaction(params) |
| 187 | + |
| 188 | + if common_params is not None: |
| 189 | + common_params.apply_common_params(transaction, client) |
| 190 | + |
| 191 | + response = transaction.execute(client, wait_for_receipt=False) |
| 192 | + receipt: TransactionReceipt = response.get_receipt(client, validate_status=True) |
| 193 | + |
| 194 | + return SignScheduleResponse(status=ResponseCode(receipt.status).name) |
| 195 | + |
| 196 | + |
155 | 197 | @rpc_method("deleteSchedule") |
156 | 198 | def delete_schedule(params: DeleteScheduleParams) -> DeleteScheduleResponse: |
157 | 199 | """Handles the deleteSchedule JSON-RPC request.""" |
|
0 commit comments