@@ -1308,6 +1308,31 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
13081308 http .Error (w , "Data set not found" , http .StatusNotFound )
13091309 return
13101310 }
1311+ type DeletePiecePayload struct {
1312+ ExtraData * string `json:"extraData"`
1313+ }
1314+ var payload DeletePiecePayload
1315+ err = json .NewDecoder (r .Body ).Decode (& payload )
1316+
1317+ // if the request body is empty, json.Decode will return io.EOF
1318+ if err != nil && ! errors .Is (err , io .EOF ) {
1319+ http .Error (w , "Invalid request body: " + err .Error (), http .StatusBadRequest )
1320+ return
1321+ }
1322+ defer func () {
1323+ _ = r .Body .Close ()
1324+ }()
1325+
1326+ var extraDataBytes []byte
1327+ if payload .ExtraData != nil {
1328+ extraDataHexStr := * payload .ExtraData
1329+ extraDataBytes , err = hex .DecodeString (strings .TrimPrefix (extraDataHexStr , "0x" ))
1330+ if err != nil {
1331+ log .Errorf ("Failed to decode hex extraData: %v" , err )
1332+ http .Error (w , "Invalid extraData format (must be hex encoded)" , http .StatusBadRequest )
1333+ return
1334+ }
1335+ }
13111336
13121337 // Get the ABI and pack the transaction data
13131338 abiData , err := contract .PDPVerifierMetaData .GetAbi ()
@@ -1320,7 +1345,7 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
13201345 data , err := abiData .Pack ("schedulePieceDeletions" ,
13211346 big .NewInt (int64 (dataSetId )),
13221347 []* big.Int {big .NewInt (int64 (pieceID ))},
1323- []byte {} ,
1348+ []byte ( extraDataBytes ) ,
13241349 )
13251350 if err != nil {
13261351 http .Error (w , "Failed to pack method call: " + err .Error (), http .StatusInternalServerError )
@@ -1372,8 +1397,17 @@ func (p *PDPService) handleDeleteDataSetPiece(w http.ResponseWriter, r *http.Req
13721397 return
13731398 }
13741399
1375- // Return 204 No Content on successful deletion
1376- w .WriteHeader (http .StatusNoContent )
1400+ response := struct {
1401+ TxHash string `json:"txHash"`
1402+ }{
1403+ TxHash : txHashLower ,
1404+ }
1405+ // Send JSON response
1406+ w .Header ().Set ("Content-Type" , "application/json" )
1407+ if err := json .NewEncoder (w ).Encode (response ); err != nil {
1408+ http .Error (w , "Failed to encode response: " + err .Error (), http .StatusInternalServerError )
1409+ return
1410+ }
13771411}
13781412
13791413func (p * PDPService ) handleGetDataSetPiece (w http.ResponseWriter , r * http.Request ) {
0 commit comments