-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.ts
38 lines (34 loc) · 976 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import type postgres from 'postgres';
import type { BlockInfo, TransactionInfo, Event, Action } from './types';
export function createBlockInfo(row: postgres.Row) {
return {
height: row.height,
stateHash: row.state_hash,
parentHash: row.parent_hash,
ledgerHash: row.ledger_hash,
chainStatus: row.chain_status,
timestamp: row.timestamp,
globalSlotSinceHardfork: row.global_slot_since_hard_fork,
globalSlotSinceGenesis: row.global_slot_since_genesis,
distanceFromMaxBlockHeight: row.distance_from_max_block_height,
} as BlockInfo;
}
export function createTransactionInfo(row: postgres.Row) {
return {
status: row.status,
hash: row.hash,
memo: row.memo,
authorizationKind: row.authorization_kind,
} as TransactionInfo;
}
export function createEvent(index: string, data: string[]) {
return {
index,
data,
} as Event;
}
export function createAction(data: string[]) {
return {
data,
} as Action;
}