Merge pull request #676 from cosmos/nanoseconds-on-commit-sigs

Nanoseconds on commit sigs
This commit is contained in:
Simon Warta 2021-02-11 23:26:11 +01:00 committed by GitHub
commit c0f30bdfca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 13 deletions

View File

@ -1,7 +1,7 @@
import { fromBase64, fromHex } from "@cosmjs/encoding";
import { ReadonlyDate } from "readonly-date";
import { ReadonlyDateWithNanoseconds } from "../../responses";
import { ReadonlyDateWithNanoseconds } from "../../types";
import { hashBlock, hashTx } from "./hasher";
describe("Hasher", () => {

View File

@ -417,7 +417,7 @@ function decodeCommitSignature(data: RpcSignature): CommitSignature {
return {
blockIdFlag: decodeBlockIdFlag(data.block_id_flag),
validatorAddress: fromHex(data.validator_address),
timestamp: new Date(assertNotEmpty(data.timestamp)),
timestamp: DateTime.decode(assertNotEmpty(data.timestamp)),
signature: fromBase64(assertNotEmpty(data.signature)),
};
}

View File

@ -9,7 +9,7 @@ import {
encodeTime,
encodeVersion,
} from "./encodings";
import { ReadonlyDateWithNanoseconds } from "./responses";
import { ReadonlyDateWithNanoseconds } from "./types";
describe("encodings", () => {
describe("DateTime", () => {

View File

@ -1,7 +1,8 @@
import { fromRfc3339, toUtf8 } from "@cosmjs/encoding";
import { Int53 } from "@cosmjs/math";
import { BlockId, ReadonlyDateWithNanoseconds, Version } from "./responses";
import { BlockId, Version } from "./responses";
import { ReadonlyDateWithNanoseconds } from "./types";
/**
* A runtime checker that ensures a given value is set (i.e. not undefined or null)

View File

@ -56,7 +56,6 @@ export {
NodeInfo,
ProofOp,
QueryProof,
ReadonlyDateWithNanoseconds,
Response,
StatusResponse,
SyncInfo,
@ -73,4 +72,10 @@ export {
VoteType,
} from "./responses";
export { HttpClient, WebsocketClient } from "./rpcclients"; // TODO: Why do we export those outside of this package?
export { BlockIdFlag, CommitSignature, ValidatorEd25519Pubkey, ValidatorPubkey } from "./types";
export {
BlockIdFlag,
CommitSignature,
ReadonlyDateWithNanoseconds,
ValidatorEd25519Pubkey,
ValidatorPubkey,
} from "./types";

View File

@ -1,6 +1,6 @@
import { ReadonlyDate } from "readonly-date";
import { CommitSignature, ValidatorPubkey } from "./types";
import { CommitSignature, ReadonlyDateWithNanoseconds, ValidatorPubkey } from "./types";
export type Response =
| AbciInfoResponse
@ -253,11 +253,6 @@ export interface Version {
readonly app: number;
}
export interface ReadonlyDateWithNanoseconds extends ReadonlyDate {
/* Nanoseconds after the time stored in a vanilla ReadonlyDate (millisecond granularity) */
readonly nanoseconds?: number;
}
// https://github.com/tendermint/tendermint/blob/v0.31.8/docs/spec/blockchain/blockchain.md
export interface Header {
// basic block info

View File

@ -1,5 +1,11 @@
// Types in this file are exported outside of the @cosmjs/tendermint-rpc package,
// e.g. as part of a request or response
import { ReadonlyDate } from "readonly-date";
export interface ReadonlyDateWithNanoseconds extends ReadonlyDate {
/* Nanoseconds after the time stored in a vanilla ReadonlyDate (millisecond granularity) */
readonly nanoseconds?: number;
}
export interface ValidatorEd25519Pubkey {
readonly algorithm: "ed25519";
@ -23,6 +29,6 @@ export enum BlockIdFlag {
export interface CommitSignature {
blockIdFlag: BlockIdFlag;
validatorAddress: Uint8Array;
timestamp?: Date;
timestamp?: ReadonlyDateWithNanoseconds;
signature: Uint8Array;
}