diff --git a/types/result.go b/types/result.go index d7e231d80..c7f2d565c 100644 --- a/types/result.go +++ b/types/result.go @@ -8,9 +8,9 @@ import ( // CONTRACT: a zero Result is OK. type Result struct { - Code CodeType - Data data.Bytes - Log string // Can be non-deterministic + Code CodeType `json:"code"` + Data data.Bytes `json:"data"` + Log string `json:"log"` // Can be non-deterministic } func NewResult(code CodeType, data []byte, log string) Result { @@ -86,3 +86,47 @@ func NewError(code CodeType, log string) Result { Log: log, } } + +//---------------------------------------- +// Convenience methods for turning the +// pb type into one using data.Bytes + +// Convert ResponseCheckTx to standard Result +func (r *ResponseCheckTx) Result() Result { + return Result{ + Code: r.Code, + Data: r.Data, + Log: r.Log, + } +} + +// Convert ResponseDeliverTx to standard Result +func (r *ResponseDeliverTx) Result() Result { + return Result{ + Code: r.Code, + Data: r.Data, + Log: r.Log, + } +} + +type ResultQuery struct { + Code CodeType `json:"code"` + Index int64 `json:"index"` + Key data.Bytes `json:"key"` + Value data.Bytes `json:"value"` + Proof data.Bytes `json:"proof"` + Height uint64 `json:"height"` + Log string `json:"log"` +} + +func (r *ResponseQuery) Result() *ResultQuery { + return &ResultQuery{ + Code: r.Code, + Index: r.Index, + Key: r.Key, + Value: r.Value, + Proof: r.Proof, + Height: r.Height, + Log: r.Log, + } +}