@cross-nft-marketplace/auction-house-nft-hooks
Version:
Generic react hooks for fetching cross-nft-marketplace auctions, nfts, and data on arbitary 721s. Powers nft-components.
262 lines (247 loc) • 5.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GET_MEDIAS_QUERY = exports.GET_AUCTION_BY_MEDIA = exports.GET_ALL_AUCTIONS = exports.GET_AUCTION_BY_TOKEN_OWNER = exports.GET_AUCTION_BY_CURATOR = void 0;
const graphql_request_1 = require("graphql-request");
const MEDIA_PARTIALS = graphql_request_1.gql `
fragment AskPrice on Ask {
id
currency {
...CurrencyShort
}
amount
createdAtTimestamp
}
fragment NFTMedia on Media {
id
creatorBidShare
ownerBidShare
owner {
id
}
creator {
id
}
currentAsk {
...AskPrice
}
createdAtTimestamp
metadataURI
metadataHash
contentURI
contentHash
}
`;
const AUCTION_PARTIALS = graphql_request_1.gql `
fragment CurrencyShort on Currency {
id
name
symbol
decimals
}
fragment PreviousReserveBid on InactiveReserveAuctionBid {
id
bidder {
id
}
transactionHash
createdAtTimestamp
amount
currency {
...CurrencyShort
}
bidType
buyNowRequested
buyNowActual
bidInactivatedAtTimestamp
bidInactivatedAtBlockNumber
}
fragment CurrentReserveBid on ReserveAuctionBid {
id
bidder {
id
}
transactionHash
createdAtTimestamp
amount
currency {
...CurrencyShort
}
bidType
buyNowRequested
buyNowActual
}
fragment ReserveAuctionPartial on ReserveAuction {
id
tokenId
tokenContract
transactionHash
status
approved
reservePrice
buyNowPrice
reserveAndBuyNowCurrency {
...CurrencyShort
}
firstBidTime
token
createdAtTimestamp
approvedTimestamp
curator {
id
}
curatorFeePercentage
tokenOwner {
id
}
auctionCurrencies {
...CurrencyShort
}
currentBid {
...CurrentReserveBid
}
previousBids {
...PreviousReserveBid
}
duration
expectedEndTimestamp
finalizedAtTimestamp
}
`;
exports.GET_AUCTION_BY_CURATOR = graphql_request_1.gql `
${AUCTION_PARTIALS}
${MEDIA_PARTIALS}
fragment ReserveAuctionPartialWithMedia on ReserveAuction {
...ReserveAuctionPartial
media {
...NFTMedia
}
}
query getAuctionsByCurator(
$curators: [String!]
$approved: [Boolean!]
$first: Int
$skip: Int
) {
reserveAuctions(
where: { curator_in: $curators, approved_in: $approved, status_not: Canceled }
first: $first
skip: $skip
orderBy: createdAtTimestamp
orderDirection: desc
) {
...ReserveAuctionPartialWithMedia
}
}
`;
exports.GET_AUCTION_BY_TOKEN_OWNER = graphql_request_1.gql `
${AUCTION_PARTIALS}
${MEDIA_PARTIALS}
fragment ReserveAuctionPartialWithMedia on ReserveAuction {
...ReserveAuctionPartial
media {
...NFTMedia
}
}
query getAuctionsByOwner(
$curators: [String!]
$owner: String!
$approved: [Boolean!]
$first: Int
$skip: Int
) {
reserveAuctions(
where: { curator_in: $curators, tokenOwner: $owner, approved_in: $approved, status_in: [Active, Pending] }
first: $first
skip: $skip
orderBy: createdAtTimestamp
orderDirection: desc
) {
...ReserveAuctionPartialWithMedia
}
}
`;
exports.GET_ALL_AUCTIONS = graphql_request_1.gql `
${AUCTION_PARTIALS}
query getAllAuctions($approved: [Boolean!], $first: Int, $skip: Int) {
reserveAuctions(where: { approved_in: $approved, status_not: Canceled }, first: $first, skip: $skip) {
...ReserveAuctionPartial
}
}
`;
exports.GET_AUCTION_BY_MEDIA = graphql_request_1.gql `
${AUCTION_PARTIALS}
query getAuctionByMedia($tokens: [String!]) {
reserveAuctions(
first: 300
where: { token_in: $tokens, status_not: Canceled }
orderBy: createdAtTimestamp
orderDirection: desc
) {
...ReserveAuctionPartial
}
}
`;
exports.GET_MEDIAS_QUERY = graphql_request_1.gql `
${AUCTION_PARTIALS}
${MEDIA_PARTIALS}
fragment BidDataPartial on Bid {
id
bidder {
id
}
createdAtTimestamp
transactionHash
amount
currency {
...CurrencyShort
}
}
fragment TransferPartial on Transfer {
id
transactionHash
from {
id
}
to {
id
}
createdAtTimestamp
createdAtBlockNumber
}
fragment NFTMediaFullData on Media {
...NFTMedia
currentBids {
...BidDataPartial
}
transfers {
...TransferPartial
}
reserveAuctions(orderBy: createdAtTimestamp, orderDirection: desc, first: 1) {
...ReserveAuctionPartial
}
}
query getMediaAndAuctions(
$id_ids: [ID!]
$creator_ids: [String!]
$owner_ids: [String!]
) {
id: medias(
where: { id_in: $id_ids }
first: 500
) {
...NFTMediaFullData
}
creator: medias(
where: { creator_in: $creator_ids }
first: 500
) {
...NFTMediaFullData
}
owner: medias(
where: { owner_in: $owner_ids }
first: 500
) {
...NFTMediaFullData
}
}
`;