|
6 | 6 | import com.hedera.hashgraph.tck.annotation.JSONRPC2Service; |
7 | 7 | import com.hedera.hashgraph.tck.methods.AbstractJSONRPC2Service; |
8 | 8 | import com.hedera.hashgraph.tck.methods.sdk.param.schedule.ScheduleCreateParams; |
| 9 | +import com.hedera.hashgraph.tck.methods.sdk.param.schedule.ScheduleSignParams; |
9 | 10 | import com.hedera.hashgraph.tck.methods.sdk.response.ScheduleResponse; |
10 | 11 | import com.hedera.hashgraph.tck.util.KeyUtils; |
11 | 12 | import com.hedera.hashgraph.tck.util.TransactionBuilders; |
@@ -78,6 +79,33 @@ public ScheduleResponse createSchedule(final ScheduleCreateParams params) throws |
78 | 79 | return new ScheduleResponse(scheduleId, transactionId, receipt.status); |
79 | 80 | } |
80 | 81 |
|
| 82 | + @JSONRPC2Method("signSchedule") |
| 83 | + public ScheduleResponse signSchedule(final ScheduleSignParams params) throws Exception { |
| 84 | + ScheduleSignTransaction transaction = new ScheduleSignTransaction().setGrpcDeadline(DEFAULT_GRPC_DEADLINE); |
| 85 | + |
| 86 | + params.getScheduleId() |
| 87 | + .ifPresent(scheduleIdStr -> transaction.setScheduleId(ScheduleId.fromString(scheduleIdStr))); |
| 88 | + |
| 89 | + params.getCommonTransactionParams() |
| 90 | + .ifPresent(common -> common.fillOutTransaction(transaction, sdkService.getClient())); |
| 91 | + |
| 92 | + TransactionResponse txResponse = transaction.execute(sdkService.getClient()); |
| 93 | + TransactionReceipt receipt = txResponse.getReceipt(sdkService.getClient()); |
| 94 | + |
| 95 | + String scheduleId = ""; |
| 96 | + String transactionId = ""; |
| 97 | + if (receipt.status == Status.SUCCESS) { |
| 98 | + if (params.getScheduleId().isPresent()) { |
| 99 | + scheduleId = params.getScheduleId().get(); |
| 100 | + } |
| 101 | + if (receipt.scheduledTransactionId != null) { |
| 102 | + transactionId = receipt.scheduledTransactionId.toString(); |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + return new ScheduleResponse(scheduleId, transactionId, receipt.status); |
| 107 | + } |
| 108 | + |
81 | 109 | /** |
82 | 110 | * Builds a scheduled transaction from method name and parameters |
83 | 111 | */ |
|
0 commit comments