Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Aug 7, 2023
1 parent f9ef0fd commit 0ec8649
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
16 changes: 6 additions & 10 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,16 @@ func (b *Blob) Namespace() share.Namespace {
}

type jsonBlob struct {
Namespace share.Namespace `json:"namespace"`
// According to the Go documentation:
// Array and slice values encode as JSON arrays,
// except that []byte encodes as a base64-encoded string.
// So, this led to the incorrect representation of the `Data`.
Data string `json:"data"`
ShareVersion uint32 `json:"share_version"`
Commitment Commitment `json:"commitment"`
Namespace share.Namespace `json:"namespace"`
Data []byte `json:"data"`
ShareVersion uint32 `json:"share_version"`
Commitment Commitment `json:"commitment"`
}

func (b *Blob) MarshalJSON() ([]byte, error) {
blob := &jsonBlob{
Namespace: b.Namespace(),
Data: string(b.Data),
Data: b.Data,
ShareVersion: b.ShareVersion,
Commitment: b.Commitment,
}
Expand All @@ -173,7 +169,7 @@ func (b *Blob) UnmarshalJSON(data []byte) error {

b.Blob.NamespaceVersion = uint32(blob.Namespace.Version())
b.Blob.NamespaceId = blob.Namespace.ID()
b.Blob.Data = []byte(blob.Data)
b.Blob.Data = blob.Data
b.Blob.ShareVersion = blob.ShareVersion
b.Commitment = blob.Commitment
b.namespace = blob.Namespace
Expand Down
4 changes: 2 additions & 2 deletions cmd/celestia/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ func init() {
getCmd.PersistentFlags().BoolVar(
&plaintext,
"plaintext",
false,
true,
"printed blob's data as a plain text",
)
getAllCmd.PersistentFlags().BoolVar(
&plaintext,
"plaintext",
false,
true,
"printed blob's data as a plain text",
)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/celestia/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func parseParams(method string, params []string) []interface{} {
panic(fmt.Sprintf("Error parsing namespace: %v", err))
}
parsedParams[1] = namespace
return parsedParams
case "QueryDelegation", "QueryUnbonding", "BalanceForAddress":
var err error
if err = validateParamsFn(len(params), 2); err != nil {
Expand Down

0 comments on commit 0ec8649

Please sign in to comment.