-
Notifications
You must be signed in to change notification settings - Fork 695
Expand file tree
/
Copy pathblock.ts
More file actions
68 lines (64 loc) · 2.26 KB
/
block.ts
File metadata and controls
68 lines (64 loc) · 2.26 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { ApiResource } from '../../types';
import type {
BlocksResponse,
BlockTransactionsResponse,
Block,
BlockFilters,
BlockWithdrawalsResponse,
BlockCountdownResponse,
BlockInternalTransactionsResponse,
} from 'types/api/block';
import type { DepositsResponse } from 'types/api/deposits';
import type { TTxsWithBlobsFilters } from 'types/api/txsFilters';
export const GENERAL_API_BLOCK_RESOURCES = {
blocks: {
path: '/api/v2/blocks',
filterFields: [ 'type' as const ],
paginated: true,
},
block: {
path: '/api/v2/blocks/:height_or_hash',
pathParams: [ 'height_or_hash' as const ],
},
block_txs: {
path: '/api/v2/blocks/:height_or_hash/transactions',
pathParams: [ 'height_or_hash' as const ],
filterFields: [ 'type' as const ],
paginated: true,
},
block_internal_txs: {
path: '/api/v2/blocks/:height_or_hash/internal-transactions',
pathParams: [ 'height_or_hash' as const ],
paginated: true,
},
block_deposits: {
path: '/api/v2/blocks/:height_or_hash/beacon/deposits',
pathParams: [ 'height_or_hash' as const ],
filterFields: [],
paginated: true,
},
block_withdrawals: {
path: '/api/v2/blocks/:height_or_hash/withdrawals',
pathParams: [ 'height_or_hash' as const ],
filterFields: [],
paginated: true,
},
} satisfies Record<string, ApiResource>;
export type GeneralApiBlockResourceName = `general:${ keyof typeof GENERAL_API_BLOCK_RESOURCES }`;
/* eslint-disable @stylistic/indent */
export type GeneralApiBlockResourcePayload<R extends GeneralApiBlockResourceName> =
R extends 'general:blocks' ? BlocksResponse :
R extends 'general:block' ? Block :
R extends 'general:block_countdown' ? BlockCountdownResponse :
R extends 'general:block_txs' ? BlockTransactionsResponse :
R extends 'general:block_internal_txs' ? BlockInternalTransactionsResponse :
R extends 'general:block_withdrawals' ? BlockWithdrawalsResponse :
R extends 'general:block_deposits' ? DepositsResponse :
never;
/* eslint-enable @stylistic/indent */
/* eslint-disable @stylistic/indent */
export type GeneralApiBlockPaginationFilters<R extends GeneralApiBlockResourceName> =
R extends 'general:blocks' ? BlockFilters :
R extends 'general:block_txs' ? TTxsWithBlobsFilters :
never;
/* eslint-enable @stylistic/indent */