Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(explored): add contractRevisions APIs #759

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading