@ledgerhq/coin-hedera
Version:
Ledger Hedera Coin integration
20 lines • 860 B
JavaScript
import { SYNTHETIC_BLOCK_WINDOW_SECONDS } from "../constants";
import { getBlockHash } from "./utils";
/**
* Retrieves synthetic block information based on the provided block height.
*
* @param blockHeight - The height of the block for which to retrieve information.
* @param blockWindowSeconds - The duration in seconds that defines the synthetic block window (default is SYNTHETIC_BLOCK_WINDOW_SECONDS).
* @returns An object containing the block height, block hash, and block time.
*/
export const getBlockInfo = async (blockHeight, blockWindowSeconds = SYNTHETIC_BLOCK_WINDOW_SECONDS) => {
const seconds = blockHeight * blockWindowSeconds;
const hash = getBlockHash(blockHeight);
const time = new Date(seconds * 1000);
return {
height: blockHeight,
hash,
time,
};
};
//# sourceMappingURL=getBlockInfo.js.map