Skip to content

Commit

Permalink
Added BlobProof response type
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna committed Dec 9, 2024
1 parent e593865 commit b00b62a
Show file tree
Hide file tree
Showing 2 changed files with 34 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))
}
33 changes: 33 additions & 0 deletions cmd/api/handler/responses/blobProof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-FileCopyrightText: 2024 PK Lab AG <[email protected]>
// SPDX-License-Identifier: MIT

package responses

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

type BlobProof struct {
Start int32 `example:"0" format:"integer" json:"start" swaggertype:"integer"`

Check failure on line 12 in cmd/api/handler/responses/blobProof.go

View workflow job for this annotation

GitHub Actions / Linter

tag is not aligned, should be: example:"0" format:"integer" json:"start" swaggertype:"integer" (tagalign)
End int32 `example:"16" format:"integer" json:"end" swaggertype:"integer"`

Check failure on line 13 in cmd/api/handler/responses/blobProof.go

View workflow job for this annotation

GitHub Actions / Linter

tag is not aligned, should be: example:"16" format:"integer" json:"end" swaggertype:"integer" (tagalign)
Nodes []string `json:"nodes"`
}

func NewProofs(proofs []*proof.NMTProof) []BlobProof {
result := make([]BlobProof, len(proofs))

for i := range proofs {
proofNodes := make([]string, len(proofs[i].Nodes))
for j, node := range proofs[i].Nodes {
proofNodes[j] = base64.StdEncoding.EncodeToString(node)
}

result[i] = BlobProof{
Start: proofs[i].Start,
End: proofs[i].End,
Nodes: proofNodes,
}
}
return result
}

0 comments on commit b00b62a

Please sign in to comment.