Reorganize ReadonlyDateWithNanoseconds

This commit is contained in:
Ethan Frey 2021-02-11 21:08:09 +01:00
parent f0ad11b69e
commit 649fcdebab
6 changed files with 19 additions and 12 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

@ -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;
}