Skip to content

Commit 367683d

Browse files
committed
refactor(ogmios-block-type-mapping): add block type; transaction cbor
1 parent 0d138c9 commit 367683d

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/mappers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export const mapBlock = (
492492
: Cardano.SlotLeader(blockModel.slot_leader_hash.toString('hex')),
493493
totalOutput: BigInt(blockOutputModel?.output ?? 0),
494494
txCount: Number(blockModel.tx_count),
495+
type: blockModel.type,
495496
vrf: blockModel.vrf as unknown as Cardano.VrfVkBech32
496497
});
497498

packages/cardano-services/src/ChainHistory/DbSyncChainHistory/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface BlockModel {
1919
slot_no: string;
2020
time: string;
2121
tx_count: string;
22+
type: Cardano.BlockType;
2223
vrf: string;
2324
}
2425

packages/core/src/Cardano/types/Block.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ VrfVkBech32.fromHex = (value: string) => {
7777
return VrfVkBech32(BaseEncoding.bech32.encode('vrf_vk', words, 1023));
7878
};
7979

80+
export type BlockType = 'bft' | 'praos';
81+
8082
/** Minimal Block type meant as a base for the more complete version `Block` */
8183
// TODO: optionals (except previousBlock) are there because they are not calculated for Byron yet.
8284
// Remove them once calculation is done and remove the Required<BlockMinimal> from interface Block
@@ -89,6 +91,7 @@ export interface BlockInfo {
8991
/** Byron blocks size not calculated yet */
9092
size?: BlockSize;
9193
previousBlock?: BlockId;
94+
type: BlockType;
9295
vrf?: VrfVkBech32;
9396
/**
9497
* This is the operational cold verification key of the stake pool

packages/core/src/Cardano/types/Transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { PlutusData } from './PlutusData';
1111
import { ProposalProcedure, VotingProcedures } from './Governance';
1212
import { RewardAccount } from '../Address';
1313
import { Script } from './Script';
14+
import { Serialization } from '../..';
1415

1516
/** transaction hash as hex string */
1617
export type TransactionId = OpaqueString<'TransactionId'>;
@@ -151,6 +152,7 @@ export interface OnChainTx<TBody extends TxBody = TxBody>
151152
extends Omit<TxWithInputSource<TBody>, 'witness' | 'auxiliaryData'> {
152153
witness: Omit<Witness, 'scripts'>;
153154
auxiliaryData?: Omit<AuxiliaryData, 'scripts'>;
155+
cbor?: Serialization.TxCBOR;
154156
}
155157

156158
export interface HydratedTx extends TxWithInputSource<HydratedTxBody> {

packages/ogmios/src/ogmiosToCore/block.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const mapByronBlock = (block: Schema.BlockBFT): Cardano.Block => ({
7474
size: mapBlockSize(block),
7575
totalOutput: mapTotalOutputs(block),
7676
txCount: mapTxCount(block),
77+
type: block.type,
7778
vrf: undefined // no vrf key for byron. DbSync doesn't have one either
7879
});
7980

@@ -86,6 +87,7 @@ const mapCommonBlock = (block: CommonBlock): Cardano.Block => ({
8687
size: mapBlockSize(block),
8788
totalOutput: mapTotalOutputs(block),
8889
txCount: mapTxCount(block),
90+
type: block.type,
8991
vrf: mapCommonVrf(block)
9092
});
9193

packages/ogmios/test/CardanoNode/__snapshots__/ObservableOgmiosCardanoNode.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ Array [
258258
"size": 1880,
259259
"totalOutput": 29999998493561943n,
260260
"txCount": 1,
261+
"type": "praos",
261262
"vrf": "vrf_vk1ny8dyz3pa9u7v7h8l5evsmxxjq07dk6j5uda60lxe3zsya5ea20s2c6jph",
262263
},
263264
"eventType": 0,

packages/ogmios/test/ogmiosToCore/__snapshots__/block.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ Object {
632632
"size": 8511,
633633
"totalOutput": 29698651346n,
634634
"txCount": 6,
635+
"type": "praos",
635636
"vrf": "vrf_vk1afy7gefvgc9eaek64lhunxw2velmuh4467n6a2aalah7r8q68j0s4f2sa9",
636637
}
637638
`;
@@ -711,6 +712,7 @@ Object {
711712
"size": 1193,
712713
"totalOutput": 29699998493147869n,
713714
"txCount": 1,
715+
"type": "praos",
714716
"vrf": "vrf_vk1wpa9axwwassnadt8drdrzptxm285latvhhvsgv0t6zhp0akgej9sfgecvl",
715717
}
716718
`;
@@ -790,6 +792,7 @@ Object {
790792
"size": 1152,
791793
"totalOutput": 29699998492735907n,
792794
"txCount": 1,
795+
"type": "praos",
793796
"vrf": "vrf_vk1aw6s04lqkquell8drg6jjusrzd8c5259kctvxkgug5kta7nphz9qfqtr4w",
794797
}
795798
`;
@@ -846,6 +849,7 @@ Object {
846849
"size": 908,
847850
"totalOutput": 1000000n,
848851
"txCount": 1,
852+
"type": "bft",
849853
"vrf": undefined,
850854
}
851855
`;
@@ -925,6 +929,7 @@ Object {
925929
"size": 1151,
926930
"totalOutput": 29699998492941888n,
927931
"txCount": 1,
932+
"type": "praos",
928933
"vrf": "vrf_vk1aw6s04lqkquell8drg6jjusrzd8c5259kctvxkgug5kta7nphz9qfqtr4w",
929934
}
930935
`;
@@ -1157,6 +1162,7 @@ Object {
11571162
"size": 1880,
11581163
"totalOutput": 29999998493561943n,
11591164
"txCount": 1,
1165+
"type": "praos",
11601166
"vrf": "vrf_vk1ny8dyz3pa9u7v7h8l5evsmxxjq07dk6j5uda60lxe3zsya5ea20s2c6jph",
11611167
}
11621168
`;

0 commit comments

Comments
 (0)