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

Adopt YAML as human-readable text output #4433

Merged
merged 6 commits into from
May 31, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Implement YAML Marshalling for addresses
  • Loading branch information
alessio committed May 30, 2019
commit 6116ca18dd7dea6d176ac6375456c90217296962
17 changes: 17 additions & 0 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"strings"

yaml "gopkg.in/yaml.v2"

"github.com/tendermint/tendermint/crypto"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"

Expand Down Expand Up @@ -158,6 +160,11 @@ func (aa AccAddress) MarshalJSON() ([]byte, error) {
return json.Marshal(aa.String())
}

// MarshalYAML marshals to YAML using Bech32.
func (aa AccAddress) MarshalYAML() ([]byte, error) {
return yaml.Marshal(aa.String())
}

// UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (aa *AccAddress) UnmarshalJSON(data []byte) error {
var s string
Expand Down Expand Up @@ -289,6 +296,11 @@ func (va ValAddress) MarshalJSON() ([]byte, error) {
return json.Marshal(va.String())
}

// MarshalYAML marshals to YAML using Bech32.
func (va ValAddress) MarshalYAML() ([]byte, error) {
return yaml.Marshal(va.String())
}

// UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (va *ValAddress) UnmarshalJSON(data []byte) error {
var s string
Expand Down Expand Up @@ -426,6 +438,11 @@ func (ca ConsAddress) MarshalJSON() ([]byte, error) {
return json.Marshal(ca.String())
}

// MarshalYAML marshals to YAML using Bech32.
func (ca ConsAddress) MarshalYAML() ([]byte, error) {
return yaml.Marshal(ca.String())
}

// UnmarshalJSON unmarshals from JSON assuming Bech32 encoding.
func (ca *ConsAddress) UnmarshalJSON(data []byte) error {
var s string
Expand Down