Fix key/value types in RpcAbciQueryResponse

This commit is contained in:
Simon Warta 2022-06-28 15:30:15 +02:00
parent 92ee134a12
commit a78a5dfdc5
3 changed files with 34 additions and 12 deletions

View File

@ -25,6 +25,8 @@ and this project adheres to
- @cosmjs/tendermint-rpc: Fix decoding validator updates due to slashing
([#1177]).
- @cosmjs/math: Check for negative values in `Decimal.fromAtomics` ([#1188]).
- @cosmjs/tendermint-rpc: Fix `key` and `value` type in `RpcAbciQueryResponse`
to also include the `null` option.
[#1170]: https://github.com/cosmos/cosmjs/issues/1170
[#1177]: https://github.com/cosmos/cosmjs/issues/1177

View File

@ -68,10 +68,20 @@ function decodeQueryProof(data: RpcQueryProof): responses.QueryProof {
}
interface RpcAbciQueryResponse {
/** base64 encoded */
readonly key: string;
/** base64 encoded */
readonly value?: string;
/**
* Base64 encoded
*
* This can be null since this iy a byte slice and due to
* https://github.com/tendermint/tendermint/blob/v0.34.19/abci/types/result.go#L50
*/
readonly key?: string | null;
/**
* Base64 encoded
*
* This can be null since this is a byte slice and due to
* https://github.com/tendermint/tendermint/blob/v0.34.19/abci/types/result.go#L50
*/
readonly value?: string | null;
readonly proofOps?: RpcQueryProof | null;
readonly height?: string;
/** An integer; can be negative */
@ -84,8 +94,8 @@ interface RpcAbciQueryResponse {
function decodeAbciQuery(data: RpcAbciQueryResponse): responses.AbciQueryResponse {
return {
key: fromBase64(optional(data.key, "")),
value: fromBase64(optional(data.value, "")),
key: fromBase64(assertString(data.key ?? "")),
value: fromBase64(assertString(data.value ?? "")),
proof: may(decodeQueryProof, data.proofOps),
height: may(Integer.parse, data.height),
code: may(Integer.parse, data.code),

View File

@ -68,10 +68,20 @@ function decodeQueryProof(data: RpcQueryProof): responses.QueryProof {
}
interface RpcAbciQueryResponse {
/** base64 encoded */
readonly key: string;
/** base64 encoded */
readonly value?: string;
/**
* Base64 encoded
*
* This can be null since this is a byte slice and due to
* https://github.com/tendermint/tendermint/blob/v0.35.7/abci/types/result.go#L53
*/
readonly key?: string | null;
/**
* Base64 encoded
*
* This can be null since this is a byte slice and due to
* https://github.com/tendermint/tendermint/blob/v0.35.7/abci/types/result.go#L53
*/
readonly value?: string | null;
readonly proofOps?: RpcQueryProof | null;
readonly height?: string;
readonly index?: string;
@ -83,8 +93,8 @@ interface RpcAbciQueryResponse {
function decodeAbciQuery(data: RpcAbciQueryResponse): responses.AbciQueryResponse {
return {
key: fromBase64(optional(data.key, "")),
value: fromBase64(optional(data.value, "")),
key: fromBase64(assertString(data.key ?? "")),
value: fromBase64(assertString(data.value ?? "")),
proof: may(decodeQueryProof, data.proofOps),
height: may(Integer.parse, data.height),
code: may(Integer.parse, data.code),