Merge pull request #281 from CosmWasm/269-tendermint-0.33-genesis-response

Fix genesis response type
This commit is contained in:
Will Clark 2020-07-07 12:13:23 +02:00 committed by GitHub
commit 6acfc0e8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -51,6 +51,14 @@ function defaultTestSuite(rpcFactory: () => RpcClient, adaptor: Adaptor): void {
client.disconnect();
});
it("can get genesis", async () => {
pendingWithoutTendermint();
const client = new Client(rpcFactory(), adaptor);
const genesis = await client.genesis();
expect(genesis).toBeTruthy();
client.disconnect();
});
it("can post a transaction", async () => {
pendingWithoutTendermint();
const client = new Client(rpcFactory(), adaptor);

View File

@ -419,7 +419,9 @@ interface RpcGenesisResponse {
readonly genesis_time: DateTimeString;
readonly chain_id: string;
readonly consensus_params: RpcConsensusParams;
readonly validators: readonly RpcValidatorGenesis[];
// The validators key is used to specify a set of validators for testnets or PoA blockchains.
// PoS blockchains use the app_state.genutil.gentxs field to stake and bond a number of validators in the first block.
readonly validators?: readonly RpcValidatorGenesis[];
readonly app_hash: HexString;
readonly app_state: {} | undefined;
}
@ -433,7 +435,7 @@ function decodeGenesis(data: RpcGenesisResponse): responses.GenesisResponse {
genesisTime: DateTime.decode(assertNotEmpty(data.genesis_time)),
chainId: assertNotEmpty(data.chain_id),
consensusParams: decodeConsensusParams(data.consensus_params),
validators: assertArray(data.validators).map(decodeValidatorGenesis),
validators: data.validators ? assertArray(data.validators).map(decodeValidatorGenesis) : [],
appHash: fromHex(assertSet(data.app_hash)), // empty string in kvstore app
appState: data.app_state,
};