Skip to content

Commit

Permalink
Added BlobProof response type (#313)
Browse files Browse the repository at this point in the history
* Added BlobProof response type

* Linter fix

* Changed BlobProof.Nodes field type to [][]byte
  • Loading branch information
k-karuna authored Dec 9, 2024
1 parent e593865 commit 5cc2cfd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/api/handler/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,5 @@ func (handler *NamespaceHandler) BlobProofs(c echo.Context) error {
return handleError(c, err, handler.namespace)
}

return c.JSON(http.StatusOK, proofs.ShareProofs)
return c.JSON(http.StatusOK, responses.NewProofs(proofs.ShareProofs))
}
26 changes: 26 additions & 0 deletions cmd/api/handler/responses/blobProof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2024 PK Lab AG <[email protected]>
// SPDX-License-Identifier: MIT

package responses

import (
"github.com/celestiaorg/celestia-app/v3/pkg/proof"
)

type BlobProof struct {
Start int32 `example:"0" format:"integer" json:"start" swaggertype:"integer"`
End int32 `example:"16" format:"integer" json:"end" swaggertype:"integer"`
Nodes [][]byte `json:"nodes"`
}

func NewProofs(proofs []*proof.NMTProof) []BlobProof {
result := make([]BlobProof, len(proofs))
for i := range proofs {
result[i] = BlobProof{
Start: proofs[i].Start,
End: proofs[i].End,
Nodes: proofs[i].Nodes,
}
}
return result
}

0 comments on commit 5cc2cfd

Please sign in to comment.