Skip to content

Commit

Permalink
feat(explored): add contractRevisions APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
telestrial committed Oct 8, 2024
1 parent f61d9e3 commit 22e1dce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/curly-queens-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/explored-js': minor
'@siafoundation/explored-react': minor
'@siafoundation/explored-types': minor
---

Added contractionRevisions API.
9 changes: 9 additions & 0 deletions libs/explored-js/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import {
ConsensusNetworkParams,
ConsensusNetworkPayload,
ConsensusNetworkResponse,
ContractRevisionsParams,
ContractRevisionsPayload,
ContractRevisionsResponse,
contractRevisionsRoute,
consensusStateRoute,
ConsensusStateParams,
ConsensusStatePayload,
Expand Down Expand Up @@ -239,6 +243,11 @@ export function Explored({
ContractByPubkeyPayload,
ContractByPubkeyResponse
>(axios, 'get', contractByPubkeyRoute),
contractRevisions: buildRequestHandler<
ContractRevisionsParams,
ContractRevisionsPayload,
ContractRevisionsResponse
>(axios, 'get', contractRevisionsRoute),
// Metrics
metrics: buildRequestHandler<
MetricsParams,
Expand Down
12 changes: 12 additions & 0 deletions libs/explored-react/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
ContractByPubkeyParams,
ContractByPubkeyResponse,
contractByPubkeyRoute,
ContractRevisionsParams,
ContractRevisionsResponse,
contractRevisionsRoute,
ContractsByIDsParams,
ContractsByIDsPayload,
ContractsByIDsResponse,
Expand Down Expand Up @@ -310,6 +313,15 @@ export function useContractByPubkey(
})
}

export function useContractRevisions(
args: HookArgsSwr<ContractRevisionsParams, ContractRevisionsResponse>
) {
return useGetSwr({
...args,
route: contractRevisionsRoute,
})
}

// Metrics

export function useMetrics(args: HookArgsSwr<MetricsParams, MetricsResponse>) {
Expand Down
6 changes: 6 additions & 0 deletions libs/explored-types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ export type ContractByPubkeyParams = { key: number }
export type ContractByPubkeyPayload = void
export type ContractByPubkeyResponse = ExplorerFileContract

// Returns all the revisions of the contract with the specified ID.
export const contractRevisionsRoute = '/contracts/:id/revisions'
export type ContractRevisionsParams = { id: FileContractID }
export type ContractRevisionsPayload = void
export type ContractRevisionsResponse = ExplorerFileContract[]

// Metrics

// Returns the most recent metrics about Sia.
Expand Down

0 comments on commit 22e1dce

Please sign in to comment.