Skip to content

Commit

Permalink
refactor: improve Tip type to use the new BlockId type
Browse files Browse the repository at this point in the history
  • Loading branch information
mkazlauskas committed Nov 25, 2021
1 parent 28f2ccf commit c020610
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/blockfrost/src/BlockfrostToCore.ts
Expand Up @@ -19,7 +19,7 @@ export const BlockfrostToCore = {

blockToTip: (block: Responses['block_content']): Cardano.Tip => ({
blockNo: block.height!,
hash: block.hash,
hash: Cardano.BlockId(block.hash),
slot: block.slot!
}),

Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/Cardano/types/Block.ts
@@ -1,4 +1,4 @@
import { BlockAlonzo, BlockSize } from '@cardano-ogmios/schema';
import { BlockAlonzo, BlockNo, BlockSize, Slot } from '@cardano-ogmios/schema';
import { Cardano } from '../..';
import { Epoch, Lovelace, PoolId } from '.';
import { Hash32ByteBase16 } from '../util';
Expand All @@ -8,6 +8,12 @@ import { Hash32ByteBase16 } from '../util';
*/
export type BlockId = Hash32ByteBase16<'BlockId'>;

export interface Tip {
slot: Slot;
hash: BlockId;
blockNo: BlockNo;
}

/**
* @param {string} value block hash as hex string
* @throws InvalidStringError
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Cardano/types/index.ts
Expand Up @@ -2,7 +2,7 @@ import * as Ogmios from '@cardano-ogmios/schema';
import { CustomError } from 'ts-custom-error';
import { util } from '../../util';

export { Hash64, Epoch, Tip, Slot, ExUnits } from '@cardano-ogmios/schema';
export { Epoch, Slot, ExUnits } from '@cardano-ogmios/schema';
export { Hash32ByteBase16, Hash28ByteBase16 } from '../util';
export * from './Address';
export * from './RewardAccount';
Expand Down

0 comments on commit c020610

Please sign in to comment.