diff --git a/.changeset/curly-queens-work.md b/.changeset/curly-queens-work.md new file mode 100644 index 000000000..98575441a --- /dev/null +++ b/.changeset/curly-queens-work.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/explored-js': minor +'@siafoundation/explored-react': minor +'@siafoundation/explored-types': minor +--- + +Added contractionRevisions API. diff --git a/libs/explored-js/src/api.ts b/libs/explored-js/src/api.ts index e052fb2d5..098c53f41 100644 --- a/libs/explored-js/src/api.ts +++ b/libs/explored-js/src/api.ts @@ -24,6 +24,10 @@ import { ConsensusNetworkParams, ConsensusNetworkPayload, ConsensusNetworkResponse, + ContractRevisionsParams, + ContractRevisionsPayload, + ContractRevisionsResponse, + contractRevisionsRoute, consensusStateRoute, ConsensusStateParams, ConsensusStatePayload, @@ -239,6 +243,11 @@ export function Explored({ ContractByPubkeyPayload, ContractByPubkeyResponse >(axios, 'get', contractByPubkeyRoute), + contractRevisions: buildRequestHandler< + ContractRevisionsParams, + ContractRevisionsPayload, + ContractRevisionsResponse + >(axios, 'get', contractRevisionsRoute), // Metrics metrics: buildRequestHandler< MetricsParams, diff --git a/libs/explored-react/src/hooks.ts b/libs/explored-react/src/hooks.ts index 47e0a01fb..d23bc488a 100644 --- a/libs/explored-react/src/hooks.ts +++ b/libs/explored-react/src/hooks.ts @@ -23,6 +23,9 @@ import { ContractByPubkeyParams, ContractByPubkeyResponse, contractByPubkeyRoute, + ContractRevisionsParams, + ContractRevisionsResponse, + contractRevisionsRoute, ContractsByIDsParams, ContractsByIDsPayload, ContractsByIDsResponse, @@ -310,6 +313,15 @@ export function useContractByPubkey( }) } +export function useContractRevisions( + args: HookArgsSwr +) { + return useGetSwr({ + ...args, + route: contractRevisionsRoute, + }) +} + // Metrics export function useMetrics(args: HookArgsSwr) { diff --git a/libs/explored-types/src/api.ts b/libs/explored-types/src/api.ts index 1dd0ffc40..992bea390 100644 --- a/libs/explored-types/src/api.ts +++ b/libs/explored-types/src/api.ts @@ -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.