|
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.ScheduleDeleteParams; |
9 | 10 | import com.hedera.hashgraph.tck.methods.sdk.param.schedule.ScheduleSignParams; |
10 | 11 | import com.hedera.hashgraph.tck.methods.sdk.response.ScheduleResponse; |
11 | 12 | import com.hedera.hashgraph.tck.util.KeyUtils; |
@@ -106,6 +107,33 @@ public ScheduleResponse signSchedule(final ScheduleSignParams params) throws Exc |
106 | 107 | return new ScheduleResponse(scheduleId, transactionId, receipt.status); |
107 | 108 | } |
108 | 109 |
|
| 110 | + @JSONRPC2Method("deleteSchedule") |
| 111 | + public ScheduleResponse deleteSchedule(final ScheduleDeleteParams params) throws Exception { |
| 112 | + ScheduleDeleteTransaction transaction = new ScheduleDeleteTransaction().setGrpcDeadline(DEFAULT_GRPC_DEADLINE); |
| 113 | + |
| 114 | + params.getScheduleId() |
| 115 | + .ifPresent(scheduleIdStr -> transaction.setScheduleId(ScheduleId.fromString(scheduleIdStr))); |
| 116 | + |
| 117 | + params.getCommonTransactionParams() |
| 118 | + .ifPresent(common -> common.fillOutTransaction(transaction, sdkService.getClient())); |
| 119 | + |
| 120 | + TransactionResponse txResponse = transaction.execute(sdkService.getClient()); |
| 121 | + TransactionReceipt receipt = txResponse.getReceipt(sdkService.getClient()); |
| 122 | + |
| 123 | + String scheduleId = ""; |
| 124 | + String transactionId = ""; |
| 125 | + if (receipt.status == Status.SUCCESS) { |
| 126 | + if (params.getScheduleId().isPresent()) { |
| 127 | + scheduleId = params.getScheduleId().get(); |
| 128 | + } |
| 129 | + if (receipt.scheduledTransactionId != null) { |
| 130 | + transactionId = receipt.scheduledTransactionId.toString(); |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + return new ScheduleResponse(scheduleId, transactionId, receipt.status); |
| 135 | + } |
| 136 | + |
109 | 137 | /** |
110 | 138 | * Builds a scheduled transaction from method name and parameters |
111 | 139 | */ |
|
0 commit comments