Skip to content

Commit 969df45

Browse files
committed
refactor(explored-types): rename block metrics APIs
1 parent 8c47e17 commit 969df45

File tree

5 files changed

+48
-39
lines changed

5 files changed

+48
-39
lines changed

.changeset/shiny-pugs-punch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@siafoundation/explored-js': minor
3+
'@siafoundation/explored-react': minor
4+
'@siafoundation/explored-types': minor
5+
---
6+
7+
Rename block metrics APIs.

libs/explored-js/src/api.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ import {
5656
HostByPubkeyParams,
5757
HostByPubkeyPayload,
5858
HostByPubkeyResponse,
59-
metricsRoute,
60-
MetricsParams,
61-
MetricsPayload,
62-
MetricsResponse,
63-
metricsByIDRoute,
64-
MetricsByIDParams,
65-
MetricsByIDPayload,
66-
MetricsByIDResponse,
59+
blockMetricsRoute,
60+
BlockMetricsParams,
61+
BlockMetricsPayload,
62+
BlockMetricsResponse,
63+
blockMetricsByIDRoute,
64+
BlockMetricsByIDParams,
65+
BlockMetricsByIDPayload,
66+
BlockMetricsByIDResponse,
6767
OutputSiacoinParams,
6868
OutputSiacoinPayload,
6969
OutputSiacoinResponse,
@@ -253,16 +253,16 @@ export function Explored({
253253
ContractRevisionsResponse
254254
>(axios, 'get', contractRevisionsRoute),
255255
// Metrics
256-
metrics: buildRequestHandler<
257-
MetricsParams,
258-
MetricsPayload,
259-
MetricsResponse
260-
>(axios, 'get', metricsRoute),
261-
metricsByID: buildRequestHandler<
262-
MetricsByIDParams,
263-
MetricsByIDPayload,
264-
MetricsByIDResponse
265-
>(axios, 'get', metricsByIDRoute),
256+
blockMetrics: buildRequestHandler<
257+
BlockMetricsParams,
258+
BlockMetricsPayload,
259+
BlockMetricsResponse
260+
>(axios, 'get', blockMetricsRoute),
261+
blockMetricsByID: buildRequestHandler<
262+
BlockMetricsByIDParams,
263+
BlockMetricsByIDPayload,
264+
BlockMetricsByIDResponse
265+
>(axios, 'get', blockMetricsByIDRoute),
266266
// Search
267267
searchResultType: buildRequestHandler<
268268
SearchResultTypeParams,

libs/explored-react/src/hooks.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import {
88
AddressSiafundUTXOsParams,
99
AddressSiafundUTXOsResponse,
1010
addressSiafundUTXOsRoute,
11+
BlockMetricsByIDParams,
12+
BlockMetricsByIDResponse,
13+
blockMetricsByIDRoute,
14+
BlockMetricsParams,
15+
BlockMetricsResponse,
16+
blockMetricsRoute,
1117
ConsensusNetworkParams,
1218
ConsensusNetworkResponse,
1319
consensusNetworkRoute,
@@ -33,12 +39,6 @@ import {
3339
HostByPubkeyParams,
3440
HostByPubkeyResponse,
3541
hostByPubkeyRoute,
36-
MetricsByIDParams,
37-
MetricsByIDResponse,
38-
metricsByIDRoute,
39-
MetricsParams,
40-
MetricsResponse,
41-
metricsRoute,
4242
OutputSiacoinParams,
4343
OutputSiacoinResponse,
4444
outputSiacoinRoute,
@@ -327,19 +327,21 @@ export function useContractRevisions(
327327

328328
// Metrics
329329

330-
export function useMetrics(args: HookArgsSwr<MetricsParams, MetricsResponse>) {
330+
export function useBlockMetrics(
331+
args: HookArgsSwr<BlockMetricsParams, BlockMetricsResponse>
332+
) {
331333
return useGetSwr({
332334
...args,
333-
route: metricsRoute,
335+
route: blockMetricsRoute,
334336
})
335337
}
336338

337-
export function useMetricsByID(
338-
args: HookArgsSwr<MetricsByIDParams, MetricsByIDResponse>
339+
export function useBlockMetricsByID(
340+
args: HookArgsSwr<BlockMetricsByIDParams, BlockMetricsByIDResponse>
339341
) {
340342
return useGetSwr({
341343
...args,
342-
route: metricsByIDRoute,
344+
route: blockMetricsByIDRoute,
343345
})
344346
}
345347

libs/explored-types/src/api.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
AddressBalance,
44
Block,
55
BlockID,
6+
BlockMetrics,
67
ChainIndex,
78
ConsensusNetwork,
89
ConsensusState,
@@ -15,7 +16,6 @@ import {
1516
ExplorerTransaction,
1617
FileContractID,
1718
Hash256,
18-
Metrics,
1919
Peer,
2020
PublicKey,
2121
SearchResultType,
@@ -205,16 +205,16 @@ export type ContractRevisionsResponse = ExplorerFileContract[]
205205
// Metrics
206206

207207
// Returns the most recent metrics about Sia.
208-
export const metricsRoute = '/metrics/block'
209-
export type MetricsParams = void
210-
export type MetricsPayload = void
211-
export type MetricsResponse = Metrics
208+
export const blockMetricsRoute = '/metrics/block'
209+
export type BlockMetricsParams = void
210+
export type BlockMetricsPayload = void
211+
export type BlockMetricsResponse = BlockMetrics
212212

213213
// Returns various metrics about Sia at the time of the given block ID.
214-
export const metricsByIDRoute = '/metrics/block/:id'
215-
export type MetricsByIDParams = { id: BlockID }
216-
export type MetricsByIDPayload = void
217-
export type MetricsByIDResponse = Metrics
214+
export const blockMetricsByIDRoute = '/metrics/block/:id'
215+
export type BlockMetricsByIDParams = { id: BlockID }
216+
export type BlockMetricsByIDPayload = void
217+
export type BlockMetricsByIDResponse = BlockMetrics
218218

219219
// Search
220220

libs/explored-types/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type Event = {
6565
data: string
6666
}
6767

68-
export type Metrics = {
68+
export type BlockMetrics = {
6969
index: ChainIndex
7070
difficulty: string
7171
totalHosts: number

0 commit comments

Comments
 (0)