Skip to content

Commit

Permalink
feat: add TransactionChainIndices to explored-types, sdk, and react l…
Browse files Browse the repository at this point in the history
…ibraries
  • Loading branch information
telestrial committed Sep 10, 2024
1 parent 1c94a60 commit 6c61dce
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/cold-items-notice.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 the TransactionChainIndices route types, sdk method, and react hook.
25 changes: 17 additions & 8 deletions libs/explored-js/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ import {
MetricsByIDParams,
MetricsByIDPayload,
MetricsByIDResponse,
OutputSiacoineParams,
OutputSiacoinePayload,
OutputSiacoineResponse,
outputSiacoineRoute,
OutputSiafundeParams,
OutputSiafundePayload,
OutputSiafundeResponse,
outputSiafundeRoute,
searchResultTypeRoute,
SearchResultTypeParams,
SearchResultTypePayload,
Expand Down Expand Up @@ -92,14 +100,10 @@ import {
TxpoolTransactionsParams,
TxpoolTransactionsPayload,
TxpoolTransactionsResponse,
OutputSiacoineParams,
OutputSiacoinePayload,
OutputSiacoineResponse,
outputSiacoineRoute,
OutputSiafundeParams,
OutputSiafundePayload,
OutputSiafundeResponse,
outputSiafundeRoute,
transactionChainIndicesRoute,
TransactionChainIndicesParams,
TransactionChainIndicesPayload,
TransactionChainIndicesResponse,
} from '@siafoundation/explored-types'

export function Explored({
Expand Down Expand Up @@ -182,6 +186,11 @@ export function Explored({
TransactionsByIDsPayload,
TransactionsByIDsResponse
>(axios, 'post', transactionsByIDsRoute),
transactionChainIndices: buildRequestHandler<
TransactionChainIndicesParams,
TransactionChainIndicesPayload,
TransactionChainIndicesResponse
>(axios, 'post', transactionChainIndicesRoute),
// Address
addressSiacoinUTXOs: buildRequestHandler<
AddressSiacoinUTXOsParams,
Expand Down
15 changes: 15 additions & 0 deletions libs/explored-react/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ import {
TransactionByIDParams,
TransactionByIDResponse,
transactionByIDRoute,
TransactionChainIndicesParams,
TransactionChainIndicesResponse,
transactionChainIndicesRoute,
TransactionsByIDsParams,
TransactionsByIDsPayload,
TransactionsByIDsResponse,
Expand Down Expand Up @@ -213,6 +216,18 @@ export function useTransactionsByIDs(
})
}

export function useTransactionChainIndices(
args: HookArgsSwr<
TransactionChainIndicesParams,
TransactionChainIndicesResponse
>
) {
return useGetSwr({
...args,
route: transactionChainIndicesRoute,
})
}

// Address

export function useAddressSiacoinUTXOs(
Expand Down
9 changes: 9 additions & 0 deletions libs/explored-types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ export type TransactionsByIDsParams = void
export type TransactionsByIDsPayload = { ids: TransactionID[] }
export type TransactionsByIDsResponse = ExplorerTransaction[]

export const transactionChainIndicesRoute = '/transactions/:id/indices'
export type TransactionChainIndicesParams = {
id: TransactionID
offset?: number
limit?: number
}
export type TransactionChainIndicesPayload = void
export type TransactionChainIndicesResponse = ChainIndex[]

// Address

// Returns the specified address' unspent siacoin outputs.
Expand Down

0 comments on commit 6c61dce

Please sign in to comment.