@@ -1300,6 +1300,31 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
1300
1300
http .Error (w , "Data set not found" , http .StatusNotFound )
1301
1301
return
1302
1302
}
1303
+ type DeletePiecePayload struct {
1304
+ ExtraData * string `json:"extraData"`
1305
+ }
1306
+ var payload DeletePiecePayload
1307
+ err = json .NewDecoder (r .Body ).Decode (& payload )
1308
+
1309
+ // if the request body is empty, json.Decode will return io.EOF
1310
+ if err != nil && ! errors .Is (err , io .EOF ) {
1311
+ http .Error (w , "Invalid request body: " + err .Error (), http .StatusBadRequest )
1312
+ return
1313
+ }
1314
+ defer func () {
1315
+ _ = r .Body .Close ()
1316
+ }()
1317
+
1318
+ var extraDataBytes []byte
1319
+ if payload .ExtraData != nil {
1320
+ extraDataHexStr := * payload .ExtraData
1321
+ extraDataBytes , err = hex .DecodeString (strings .TrimPrefix (extraDataHexStr , "0x" ))
1322
+ if err != nil {
1323
+ log .Errorf ("Failed to decode hex extraData: %v" , err )
1324
+ http .Error (w , "Invalid extraData format (must be hex encoded)" , http .StatusBadRequest )
1325
+ return
1326
+ }
1327
+ }
1303
1328
1304
1329
// Get the ABI and pack the transaction data
1305
1330
abiData , err := contract .PDPVerifierMetaData .GetAbi ()
@@ -1312,7 +1337,7 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
1312
1337
data , err := abiData .Pack ("schedulePieceDeletions" ,
1313
1338
big .NewInt (int64 (dataSetId )),
1314
1339
[]* big.Int {big .NewInt (int64 (pieceID ))},
1315
- []byte {} ,
1340
+ []byte ( extraDataBytes ) ,
1316
1341
)
1317
1342
if err != nil {
1318
1343
http .Error (w , "Failed to pack method call: " + err .Error (), http .StatusInternalServerError )
@@ -1364,8 +1389,17 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
1364
1389
return
1365
1390
}
1366
1391
1367
- // Return 204 No Content on successful deletion
1368
- w .WriteHeader (http .StatusNoContent )
1392
+ response := struct {
1393
+ TxHash string `json:"txHash"`
1394
+ }{
1395
+ TxHash : txHashLower ,
1396
+ }
1397
+ // Send JSON response
1398
+ w .Header ().Set ("Content-Type" , "application/json" )
1399
+ if err := json .NewEncoder (w ).Encode (response ); err != nil {
1400
+ http .Error (w , "Failed to encode response: " + err .Error (), http .StatusInternalServerError )
1401
+ return
1402
+ }
1369
1403
}
1370
1404
1371
1405
func (p * PDPService ) handleGetDataSetPiece (w http.ResponseWriter , r * http.Request ) {
0 commit comments