Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blob)!: tendermint compatible commitment proof json marshall #3929

Open
wants to merge 8 commits into
base: feature/api-breaks
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions blob/commitment_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"errors"
"fmt"

tmjson "github.com/tendermint/tendermint/libs/json"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/celestiaorg/celestia-app/v3/pkg/proof"
"github.com/celestiaorg/go-square/v2/inclusion"
Expand Down Expand Up @@ -153,3 +155,19 @@
// verify row roots to data root proof
return commitmentProof.RowProof.VerifyProof(root), nil
}

// MarshalJSON marshals an CommitmentProof to JSON. Uses tendermint encoder for row proof for compatibility.
func (c *CommitmentProof) MarshalJSON() ([]byte, error) {

Check failure on line 160 in blob/commitment_proof.go

View workflow job for this annotation

GitHub Actions / go-ci / Lint

receiver-naming: receiver name c should be consistent with previous receiver name commitmentProof for CommitmentProof (revive)
// alias the type to avoid going into recursion loop
// because tmjson.Marshal invokes custom json Marshalling

Check failure on line 162 in blob/commitment_proof.go

View workflow job for this annotation

GitHub Actions / go-ci / Lint

`Marshalling` is a misspelling of `Marshaling` (misspell)
type Alias CommitmentProof
return tmjson.Marshal((*Alias)(c))
}

// UnmarshalJSON unmarshals an CommitmentProof from JSON. Uses tendermint decoder for row proof for compatibility.
func (c *CommitmentProof) UnmarshalJSON(data []byte) error {

Check failure on line 168 in blob/commitment_proof.go

View workflow job for this annotation

GitHub Actions / go-ci / Lint

receiver-naming: receiver name c should be consistent with previous receiver name commitmentProof for CommitmentProof (revive)
// alias the type to avoid going into recursion loop
// because tmjson.Unmarshal invokes custom json Unmarshalling
type Alias CommitmentProof
return tmjson.Unmarshal(data, (*Alias)(c))
}
Loading