From 51d5280e11e09fabe8261e6097fbc8a4e5b011cf Mon Sep 17 00:00:00 2001 From: Edgar Aroutiounian Date: Tue, 10 Mar 2020 16:18:32 -0700 Subject: [PATCH] [validator] Turn int into string in JSON representation (#2454) --- staking/effective/eligible.go | 13 +++++++++++++ staking/types/validator.go | 2 ++ 2 files changed, 15 insertions(+) diff --git a/staking/effective/eligible.go b/staking/effective/eligible.go index 45ff069b2..0eb26a1fb 100644 --- a/staking/effective/eligible.go +++ b/staking/effective/eligible.go @@ -20,3 +20,16 @@ const ( // it can never be undone Banned ) + +func (e Eligibility) String() string { + switch e { + case Active: + return "active" + case Inactive: + return "inactive" + case Banned: + return "banned" + default: + return "nil" + } +} diff --git a/staking/types/validator.go b/staking/types/validator.go index 1ea3862a8..0b2106fb4 100644 --- a/staking/types/validator.go +++ b/staking/types/validator.go @@ -109,11 +109,13 @@ func (w ValidatorWrapper) MarshalJSON() ([]byte, error) { return json.Marshal(struct { Validator Address string `json:"address"` + EPOSStatus string `json:"epos-eligibility-status"` Delegations Delegations `json:"delegations"` Counters counters `json:"availability"` }{ w.Validator, common2.MustAddressToBech32(w.Address), + w.EPOSStatus.String(), w.Delegations, w.Counters, })