-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
419 additions
and
472 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
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
This file was deleted.
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
This file was deleted.
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
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 @@ | ||
export * from './useAccountInfo'; | ||
export * from './useAddress'; | ||
export * from './useAlgod'; | ||
export * from './useDataChannel'; | ||
export * from './usePeerConnection'; | ||
export * from './useSocket'; | ||
export * from './useUserState'; |
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,18 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useAlgod } from './useAlgod.ts'; | ||
|
||
export function useAccountInfo( | ||
address: string | null, | ||
refetchInterval?: number, | ||
) { | ||
const algod = useAlgod(); | ||
return useQuery({ | ||
refetchInterval, | ||
queryKey: ['accountInfo', address], | ||
queryFn: async () => { | ||
if (!algod || !address) return; | ||
return await algod.accountInformation(address).do(); | ||
}, | ||
enabled: !!algod && !!address, | ||
}); | ||
} |
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,16 @@ | ||
import { createContext, useContext } from 'react'; | ||
import { Algodv2 } from 'algosdk'; | ||
|
||
type AlgodState = { algod: Algodv2 | null }; | ||
export const AlgodContext = createContext({ | ||
algod: null, | ||
} as AlgodState); | ||
|
||
export function useAlgod() { | ||
const { algod } = useContext(AlgodContext); | ||
if (!algod) | ||
throw new Error( | ||
'Algod not found, make sure it is provided in the context.', | ||
); | ||
return algod; | ||
} |
Oops, something went wrong.