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(share)!: tendermint compatible get range result json marshall #3930

Open
wants to merge 3 commits into
base: feature/api-breaks
Choose a base branch
from
Open
Changes from all 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
17 changes: 17 additions & 0 deletions nodebuilder/share/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package share
import (
"context"

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

libshare "github.com/celestiaorg/go-square/v2/share"
Expand All @@ -23,6 +24,22 @@ type GetRangeResult struct {
Proof *types.ShareProof
}

// MarshalJSON marshals an GetRangeResult to JSON. Uses tendermint encoder for proof for compatibility.
func (r *GetRangeResult) MarshalJSON() ([]byte, error) {
// alias the type to avoid going into recursion loop
// because tmjson.Marshal invokes custom json marshaling
type Alias GetRangeResult
return tmjson.Marshal((*Alias)(r))
}

// UnmarshalJSON unmarshals an GetRangeResult from JSON. Uses tendermint decoder for proof for compatibility.
func (r *GetRangeResult) UnmarshalJSON(data []byte) error {
// alias the type to avoid going into recursion loop
// because tmjson.Unmarshal invokes custom json Unmarshaling
type Alias GetRangeResult
return tmjson.Unmarshal(data, (*Alias)(r))
}

// Module provides access to any data square or block share on the network.
//
// All Get methods provided on Module follow the following flow:
Expand Down
Loading