UNPKG

@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.

119 lines (118 loc) 2.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BY_IDS = exports.BY_OWNER = void 0; const graphql_request_1 = require("graphql-request"); const MEDIA_FRAGMENTS = graphql_request_1.gql ` fragment IndexerTokenPart on Token { id tokenId owner address tokenContract { name symbol address supportsMetadata } tokenURI minter metadata { json } mintTransferEvent { transactionHash blockTimestamp blockNumber } media { contentURI contentHash metadataHash metadataURI ownerBidShare creatorBidShare } } fragment IndexerAuctionPart on Auction { winner lastBidAmount duration tokenId auctionId tokenContract reservePrice firstBidTime expiresAt tokenOwner curator curatorFee curatorFeePercentage canceledEvent { id } endedEvent { id } bidEvents { id value sender transactionHash } } fragment IndexerAuctionWithToken on Auction { ...IndexerAuctionPart token { ...IndexerTokenPart } } `; const BASE_FRAGMENTS = graphql_request_1.gql ` ${MEDIA_FRAGMENTS} fragment IndexerTokenWithAuction on Token { ...IndexerTokenPart auctions(where: { _and: [{ _not: { canceledEvent: {} } }] }) { ...IndexerAuctionPart } } `; // Get list of nfts owned by user from contracts exports.BY_OWNER = graphql_request_1.gql ` ${BASE_FRAGMENTS} query byOwner( $addressQueryPart: String_comparison_exp! $owner: String $offset: Int $limit: Int ) @cached { Token( limit: $limit offset: $offset where: { address: $addressQueryPart _or: [ { owner: { _eq: $owner } } { auctions: { _and: [ { _not: { endedEvent: {} } } { _not: { canceledEvent: {} } } { tokenOwner: { _eq: $owner } } ] } } ] } ) { ...IndexerTokenWithAuction } } `; exports.BY_IDS = graphql_request_1.gql ` ${BASE_FRAGMENTS} query byIds($ids: [String!]) @cached { Token(where: { id: { _in: $ids } }) { ...IndexerTokenWithAuction } } `;