generated from stacks-network/.github
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
748 additions
and
992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createClient } from '@stacks/blockchain-api-client'; | ||
|
||
import packageJson from '../../package.json'; | ||
import { RELEASE_TAG_NAME } from '../common/constants/env'; | ||
|
||
export const getApiClient = (baseUrl: string) => { | ||
const apiClient = createClient({ | ||
baseUrl, | ||
}); | ||
|
||
apiClient.use({ | ||
onRequest({ request }) { | ||
request.headers.set('x-hiro-product', 'explorer'); | ||
request.headers.set('x-hiro-version', RELEASE_TAG_NAME || packageJson.version); | ||
return request; | ||
}, | ||
}); | ||
|
||
return apiClient; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getErrorMessage(error: any) { | ||
return error?.message || 'Something went wrong! Please try again later.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useGlobalContext } from '../common/context/useGlobalContext'; | ||
import { getApiClient } from './getApiClient'; | ||
|
||
export function useApiClient() { | ||
const baseUrl = useGlobalContext().activeNetworkKey; | ||
return getApiClient(baseUrl); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useApiClient } from './useApiClient'; | ||
|
||
export function useGetQueryFn(path: string) { | ||
const apiClient = useApiClient(); | ||
return apiClient.GET('/extended/v2/blocks/{height_or_hash}/transactions', { | ||
params: { | ||
path: { height_or_hash: 2000 }, | ||
query: { limit: 20, offset: 100 }, | ||
}, | ||
}); | ||
} | ||
|
||
export function useGetTransactionsQueryFn() { | ||
return useApiClient().GET('/extended/v2/blocks/{height_or_hash}/transactions', { | ||
params: { | ||
path: { height_or_hash: 2000 }, | ||
query: { limit: 20, offset: 100 }, | ||
}, | ||
}); | ||
} |
Oops, something went wrong.