-
Couldn't load subscription status.
- Fork 405
Description
Subissue of #1750
There's a lot of any in the codebase, especially for JSON/protobuf stuff.
cosmjs/packages/amino/src/pubkeys.ts
Lines 1 to 7 in ca243f5
| export interface Pubkey { | |
| // type is one of the strings defined in pubkeyType | |
| // I don't use a string literal union here as that makes trouble with json test data: | |
| // https://github.com/cosmos/cosmjs/pull/44#pullrequestreview-353280504 | |
| readonly type: string; | |
| readonly value: any; | |
| } |
cosmjs/packages/tendermint-rpc/src/tendermint34/responses.ts
Lines 239 to 245 in ca243f5
| /** | |
| * We lost track on how the evidence structure actually looks like. | |
| * This is any now and passed to the caller untouched. | |
| * | |
| * See also https://github.com/cosmos/cosmjs/issues/980. | |
| */ | |
| export type Evidence = any; |
And the parsing code looks weirdly structured and scattered around. Simple assertObject utility functions are defined 4 different times, copypasted around. Fields are checked piecemeal instead of a single pass validation to cast unknown or JsonValue to SpecificType - objects get casted as a class before actually confirming all mandatory fields are there.
cosmjs/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts
Lines 881 to 883 in ca243f5
| public static decodeGenesis(response: JsonRpcSuccessResponse): responses.GenesisResponse { | |
| return decodeGenesis(assertObject((response.result as GenesisResult).genesis)); | |
| } |
One of these could be useful:
https://www.npmjs.com/package/type-fest
https://www.npmjs.com/package/json2typescript
https://www.npmjs.com/package/typia
https://www.npmjs.com/package/@total-typescript/ts-reset