Fix broken BlockResponse types
This commit is contained in:
parent
b80d5c39fc
commit
fa78a7460c
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
20
packages/sdk/types/restclient.d.ts
vendored
20
packages/sdk/types/restclient.d.ts
vendored
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user