Skip to content

Commit dd29107

Browse files
committed
feat: node delete
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
1 parent 5c76f84 commit dd29107

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

tck/cmd/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func main() {
4343
contractService := new(methods.ContractService)
4444
contractService.SetSdkService(sdkService)
4545

46-
4746
nodeService := new(methods.NodeService)
4847
nodeService.SetSdkService(sdkService)
4948

@@ -94,6 +93,7 @@ func main() {
9493
"signSchedule": postHandler(HandleError, handler.New(scheduleService.SignSchedule)),
9594
"executeContract": postHandler(HandleError, handler.New(contractService.ExecuteContract)),
9695
"createNode": postHandler(HandleError, handler.New(nodeService.CreateNode)),
96+
"deleteNode": postHandler(HandleError, handler.New(nodeService.DeleteNode)),
9797
"generateKey": postHandler(HandleError, handler.New(methods.GenerateKey)),
9898
}
9999

tck/methods/node.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,41 @@ func (n *NodeService) CreateNode(_ context.Context, params param.CreateNodeParam
121121
return &response.NodeResponse{NodeId: nodeId, Status: receipt.Status.String()}, nil
122122
}
123123

124+
func (n *NodeService) DeleteNode(_ context.Context, params param.DeleteNodeParams) (*response.NodeResponse, error) {
125+
transaction := hiero.NewNodeDeleteTransaction().SetGrpcDeadline(&threeSecondsDuration)
126+
127+
// Set node ID
128+
if params.NodeId != nil {
129+
nodeId, err := strconv.ParseUint(*params.NodeId, 10, 64)
130+
if err != nil {
131+
return nil, err
132+
}
133+
transaction.SetNodeID(nodeId)
134+
}
135+
136+
// Set common transaction parameters
137+
if params.CommonTransactionParams != nil {
138+
err := params.CommonTransactionParams.FillOutTransaction(transaction, n.sdkService.Client)
139+
if err != nil {
140+
return nil, err
141+
}
142+
}
143+
144+
// Execute transaction
145+
txResponse, err := transaction.Execute(n.sdkService.Client)
146+
if err != nil {
147+
return nil, err
148+
}
149+
150+
// Get receipt
151+
receipt, err := txResponse.SetValidateStatus(true).GetReceipt(n.sdkService.Client)
152+
if err != nil {
153+
return nil, err
154+
}
155+
156+
return &response.NodeResponse{Status: receipt.Status.String()}, nil
157+
}
158+
124159
// convertEndpointParam converts a param.EndpointParams to hiero.Endpoint
125160
func convertEndpointParam(endpointParam param.EndpointParams) (hiero.Endpoint, error) {
126161
endpoint := hiero.Endpoint{}

tck/param/node.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ type CreateNodeParams struct {
2020
GrpcWebProxyEndpoint *EndpointParams `json:"grpcWebProxyEndpoint,omitempty"`
2121
CommonTransactionParams *CommonTransactionParams `json:"commonTransactionParams,omitempty"`
2222
}
23+
24+
type DeleteNodeParams struct {
25+
NodeId *string `json:"nodeId,omitempty"`
26+
CommonTransactionParams *CommonTransactionParams `json:"commonTransactionParams,omitempty"`
27+
}

0 commit comments

Comments
 (0)