-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:ourzora/nft-hooks into main
- Loading branch information
Showing
15 changed files
with
802 additions
and
316 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 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 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,40 @@ | ||
import { useState } from 'react'; | ||
import { ReserveAuctionPartialFragment } from 'src/graph-queries/zora-types'; | ||
|
||
import { useCallbackFetch } from './useCallbackFetch'; | ||
|
||
export type useAuctionHouseType = { | ||
loading: boolean; | ||
error?: string; | ||
auctions?: ReserveAuctionPartialFragment[]; | ||
}; | ||
|
||
/** | ||
* Fetches on-chain NFT auction data for the given curator | ||
* | ||
* @param id id of zNFT to fetch blockchain information for | ||
* @param curator | ||
* @returns useNFTType hook results include loading, error, and chainNFT data. | ||
*/ | ||
export function useAuctions( | ||
curators: readonly string[] = [], | ||
approved: boolean | null = null | ||
): useAuctionHouseType { | ||
const [auctions, setAuctions] = useState<ReserveAuctionPartialFragment[]>(); | ||
const [error, setError] = useState<string | undefined>(); | ||
|
||
useCallbackFetch(curators, async (fetchAgent, curators) => { | ||
try { | ||
let data = await fetchAgent.fetchReserveAuctions(curators, approved); | ||
setAuctions(data); | ||
} catch (err) { | ||
setError(err.toString()); | ||
} | ||
}); | ||
|
||
return { | ||
loading: !error && !auctions, | ||
error, | ||
auctions, | ||
}; | ||
} |
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
Oops, something went wrong.