Fix broken BlockResponse types

This commit is contained in:
Simon Warta 2020-02-15 15:44:12 +01:00
parent b80d5c39fc
commit fa78a7460c
3 changed files with 28 additions and 28 deletions

View File

@ -218,12 +218,12 @@ export class CosmWasmConnection implements BlockchainConnection {
public async getBlockHeader(height: number): Promise<BlockHeader> {
// tslint:disable-next-line: deprecation
const { block_meta } = await this.restClient.blocks(height);
const { block_id, block } = await this.restClient.blocks(height);
return {
id: block_meta.block_id.hash as BlockId,
height: block_meta.header.height,
time: new ReadonlyDate(block_meta.header.time),
transactionCount: block_meta.header.num_txs,
id: block_id.hash as BlockId,
height: parseInt(block.header.height, 10),
time: new ReadonlyDate(block.header.time),
transactionCount: block.data.txs?.length || 0,
};
}

View File

@ -22,20 +22,11 @@ interface NodeInfoResponse {
readonly node_info: NodeInfo;
}
export interface BlockMeta {
readonly header: {
readonly height: number;
readonly time: string;
readonly num_txs: number;
};
readonly block_id: {
readonly hash: string;
};
}
export interface BlockHeader {
readonly height: string;
readonly chain_id: string;
/** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */
readonly time: string;
// TODO: add all of those
// header: {
// version: [Object],
@ -57,10 +48,21 @@ export interface BlockHeader {
export interface Block {
readonly header: BlockHeader;
readonly data: {
/** Array of base64 encoded transactions */
readonly txs: ReadonlyArray<string> | null;
};
}
export interface BlockResponse {
readonly block_meta: BlockMeta;
readonly block_id: {
readonly hash: string;
// TODO: here we also have this
// parts: {
// total: '1',
// hash: '7AF200C78FBF9236944E1AB270F4045CD60972B7C265E3A9DA42973397572931'
// }
};
readonly block: Block;
}

View File

@ -5,25 +5,23 @@ interface NodeInfo {
interface NodeInfoResponse {
readonly node_info: NodeInfo;
}
export interface BlockMeta {
readonly header: {
readonly height: number;
readonly time: string;
readonly num_txs: number;
};
readonly block_id: {
readonly hash: string;
};
}
export interface BlockHeader {
readonly height: string;
readonly chain_id: string;
/** An RFC 3339 time string like e.g. '2020-02-15T10:39:10.4696305Z' */
readonly time: string;
}
export interface Block {
readonly header: BlockHeader;
readonly data: {
/** Array of base64 encoded transactions */
readonly txs: ReadonlyArray<string> | null;
};
}
export interface BlockResponse {
readonly block_meta: BlockMeta;
readonly block_id: {
readonly hash: string;
};
readonly block: Block;
}
interface AuthAccountsResponse {