@zoralabs/nft-hooks
Advanced tools
Comparing version
@@ -17,2 +17,4 @@ import { Maybe } from 'graphql/jsutils/Maybe'; | ||
}; | ||
export declare type AuctionResultType = ReserveAuctionPartialFragment; | ||
export declare type AuctionsResult = AuctionResultType[]; | ||
export declare type NFTMediaDataType = { | ||
@@ -19,0 +21,0 @@ nft: Omit<NftMediaFragment, 'currentBids' | 'currentAsk'> & { |
@@ -55,4 +55,48 @@ import type { NetworkIDs } from '../constants/networks'; | ||
/** | ||
* Internal fetch function to retrieve Graph data for Zora NFT IDs | ||
* Fetch function to retrieve Graph data for matching curated auctions | ||
* This function is not cached | ||
* | ||
* @function fetchReserveAuctions | ||
* @private | ||
* @param curatorIds list of Zora NFT IDs to fetch from the graph datastore | ||
* @returns mapped transformed list of curated auction results | ||
*/ | ||
fetchReserveAuctions(curatorIds: readonly string[], isApproved?: boolean | null, first?: number, skip?: number): Promise<({ | ||
__typename?: "ReserveAuction" | undefined; | ||
} & { | ||
__typename?: "ReserveAuction" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").ReserveAuction, "id" | "createdAtTimestamp" | "tokenId" | "status" | "approved" | "reservePrice" | "firstBidTime" | "curatorFeePercentage" | "duration" | "expectedEndTimestamp" | "finalizedAtTimestamp"> & { | ||
curator: { | ||
__typename?: "User" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").User, "id">; | ||
tokenOwner: { | ||
__typename?: "User" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").User, "id">; | ||
auctionCurrency: { | ||
__typename?: "Currency" | undefined; | ||
} & { | ||
__typename?: "Currency" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").Currency, "symbol" | "id" | "name" | "decimals">; | ||
currentBid?: import("../graph-queries/zora-types").Maybe<{ | ||
__typename?: "ReserveAuctionBid" | undefined; | ||
} & { | ||
__typename?: "ReserveAuctionBid" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").ReserveAuctionBid, "createdAtTimestamp" | "amount" | "bidType"> & { | ||
bidder: { | ||
__typename?: "User" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").User, "id">; | ||
}> | undefined; | ||
previousBids?: import("../graph-queries/zora-types").Maybe<({ | ||
__typename?: "InactiveReserveAuctionBid" | undefined; | ||
} & { | ||
__typename?: "InactiveReserveAuctionBid" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").InactiveReserveAuctionBid, "id" | "createdAtTimestamp" | "amount" | "bidType" | "bidInactivatedAtTimestamp" | "bidInactivatedAtBlockNumber"> & { | ||
bidder: { | ||
__typename?: "User" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").User, "id">; | ||
})[]> | undefined; | ||
})[]>; | ||
/** | ||
* Internal fetch current auctions by curator | ||
* | ||
* @function fetchMediaGraph | ||
@@ -59,0 +103,0 @@ * @private |
@@ -120,4 +120,30 @@ "use strict"; | ||
/** | ||
* Internal fetch function to retrieve Graph data for Zora NFT IDs | ||
* Fetch function to retrieve Graph data for matching curated auctions | ||
* This function is not cached | ||
* | ||
* @function fetchReserveAuctions | ||
* @private | ||
* @param curatorIds list of Zora NFT IDs to fetch from the graph datastore | ||
* @returns mapped transformed list of curated auction results | ||
*/ | ||
async fetchReserveAuctions(curatorIds, isApproved = null, first = 1000, skip = 0) { | ||
const fetchWithTimeout = new FetchWithTimeout_1.FetchWithTimeout(this.timeouts.Graph); | ||
const client = new graphql_request_1.GraphQLClient(this.graphEndpoint, { | ||
fetch: fetchWithTimeout.fetch, | ||
}); | ||
let query = zora_1.GET_ALL_AUCTIONS; | ||
if (curatorIds.length) { | ||
query = zora_1.GET_AUCTION_BY_CURATOR; | ||
} | ||
const response = (await client.request(query, { | ||
curators: curatorIds.length ? curatorIds : undefined, | ||
first: first, | ||
skip: skip, | ||
approved: isApproved === null ? [true, false] : [isApproved], | ||
})); | ||
return response.reserveAuctions; | ||
} | ||
/** | ||
* Internal fetch current auctions by curator | ||
* | ||
* @function fetchMediaGraph | ||
@@ -124,0 +150,0 @@ * @private |
@@ -71,7 +71,12 @@ import type { Currency, CurrencyShortFragment, GetMediaAndAuctionsQuery } from '../graph-queries/zora-types'; | ||
status: import("../graph-queries/zora-types").ReserveAuctionStatus; | ||
approved: boolean; | ||
reservePrice: any; | ||
firstBidTime?: any; | ||
curatorFeePercentage: number; | ||
duration: any; | ||
expectedEndTimestamp?: any; | ||
finalizedAtTimestamp?: any; | ||
curator: { | ||
__typename?: "User" | undefined; | ||
} & Pick<import("../graph-queries/zora-types").User, "id">; | ||
tokenOwner: { | ||
@@ -78,0 +83,0 @@ __typename?: "User" | undefined; |
@@ -83,3 +83,3 @@ "use strict"; | ||
function addAuctionInformation(chainNFT, currencyInfos = {}) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
const hasActiveReserveAuction = ((_a = chainNFT.pricing.reserve) === null || _a === void 0 ? void 0 : _a.status) === 'Active'; | ||
@@ -264,6 +264,6 @@ const getCurrencyComputedValue = (currencyId, bidAmount) => { | ||
reserveMet: hasActiveReserveAuction | ||
? !!((_e = chainNFT.pricing.reserve) === null || _e === void 0 ? void 0 : _e.firstBidTime) | ||
? !!((_e = chainNFT.pricing.reserve) === null || _e === void 0 ? void 0 : _e.firstBidTime) && ((_f = chainNFT.pricing.reserve) === null || _f === void 0 ? void 0 : _f.firstBidTime) !== "0" | ||
: false, | ||
endingAt: hasActiveReserveAuction | ||
? (_f = chainNFT.pricing.reserve) === null || _f === void 0 ? void 0 : _f.expectedEndTimestamp | ||
? (_g = chainNFT.pricing.reserve) === null || _g === void 0 ? void 0 : _g.expectedEndTimestamp | ||
: undefined, | ||
@@ -270,0 +270,0 @@ }, |
@@ -1,2 +0,3 @@ | ||
export declare const GET_AUCTION_QUERY: string; | ||
export declare const GET_AUCTION_BY_CURATOR: string; | ||
export declare const GET_ALL_AUCTIONS: string; | ||
export declare const GET_MEDIA_QUERY: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GET_MEDIA_QUERY = exports.GET_AUCTION_QUERY = void 0; | ||
exports.GET_MEDIA_QUERY = exports.GET_ALL_AUCTIONS = exports.GET_AUCTION_BY_CURATOR = void 0; | ||
const graphql_request_1 = require("graphql-request"); | ||
@@ -34,11 +34,2 @@ const AUCTION_PARTIALS = graphql_request_1.gql ` | ||
fragment AskPrice on Ask { | ||
id | ||
currency { | ||
...CurrencyShort | ||
} | ||
amount | ||
createdAtTimestamp | ||
} | ||
fragment ReserveAuctionPartial on ReserveAuction { | ||
@@ -48,5 +39,10 @@ id | ||
status | ||
approved | ||
reservePrice | ||
firstBidTime | ||
createdAtTimestamp | ||
curator { | ||
id | ||
} | ||
curatorFeePercentage | ||
tokenOwner { | ||
@@ -70,9 +66,14 @@ id | ||
`; | ||
exports.GET_AUCTION_QUERY = graphql_request_1.gql ` | ||
exports.GET_AUCTION_BY_CURATOR = graphql_request_1.gql ` | ||
${AUCTION_PARTIALS} | ||
query getAuctions($auctionIds: [ID!]) { | ||
reserveAuctions(where:{ | ||
id_in: $auctionIds | ||
}) { | ||
query getAuctionsByCurator($curators: [String!], $approved: [Boolean!], $first: Int, $skip: Int) { | ||
reserveAuctions(where: | ||
{ | ||
curator_in: $curators, | ||
approved_in: $approved | ||
} | ||
first: $first | ||
skip: $skip | ||
) { | ||
...ReserveAuctionPartial | ||
@@ -82,5 +83,29 @@ } | ||
`; | ||
exports.GET_ALL_AUCTIONS = graphql_request_1.gql ` | ||
${AUCTION_PARTIALS} | ||
query getAllAuctions($approved: [Boolean!], $first: Int, $skip: Int) { | ||
reserveAuctions( | ||
where: { | ||
approved_in: $approved | ||
} | ||
first: $first | ||
skip: $skip | ||
) { | ||
...ReserveAuctionPartial | ||
} | ||
} | ||
`; | ||
exports.GET_MEDIA_QUERY = graphql_request_1.gql ` | ||
${AUCTION_PARTIALS} | ||
fragment AskPrice on Ask { | ||
id | ||
currency { | ||
...CurrencyShort | ||
} | ||
amount | ||
createdAtTimestamp | ||
} | ||
fragment NFTMedia on Media { | ||
@@ -87,0 +112,0 @@ id |
@@ -7,4 +7,5 @@ import { Networks, NetworkIDs } from './constants/networks'; | ||
import { MediaFetchAgent } from './fetcher/MediaFetchAgent'; | ||
import { NFTDataType, ChainCurrencyType } from './fetcher/FetchResultTypes'; | ||
import { NFTDataType, ChainCurrencyType, AuctionResultType } from './fetcher/FetchResultTypes'; | ||
import * as ExtractResultData from './fetcher/TransformFetchResults'; | ||
export { useNFT, useNFTContent, useNFTMetadata, NFTFetchConfiguration, MediaFetchAgent, NFTDataType, ChainCurrencyType, Networks, NetworkIDs, ExtractResultData, }; | ||
import { useAuctions } from './hooks/useAuctions'; | ||
export { useNFT, useNFTContent, useNFTMetadata, useAuctions, NFTFetchConfiguration, MediaFetchAgent, AuctionResultType, NFTDataType, ChainCurrencyType, Networks, NetworkIDs, ExtractResultData, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ExtractResultData = exports.Networks = exports.MediaFetchAgent = exports.NFTFetchConfiguration = exports.useNFTMetadata = exports.useNFTContent = exports.useNFT = void 0; | ||
exports.ExtractResultData = exports.Networks = exports.MediaFetchAgent = exports.NFTFetchConfiguration = exports.useAuctions = exports.useNFTMetadata = exports.useNFTContent = exports.useNFT = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -19,1 +19,3 @@ const networks_1 = require("./constants/networks"); | ||
exports.ExtractResultData = ExtractResultData; | ||
const useAuctions_1 = require("./hooks/useAuctions"); | ||
Object.defineProperty(exports, "useAuctions", { enumerable: true, get: function () { return useAuctions_1.useAuctions; } }); |
import { FetchMockSandbox } from 'fetch-mock'; | ||
declare const fetchMock: FetchMockSandbox; | ||
export declare function getLastGraphQuery(url: string): any; | ||
export default fetchMock; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLastGraphQuery = void 0; | ||
const tslib_1 = require("tslib"); | ||
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch")); | ||
jest.mock("cross-fetch", () => require("fetch-mock-jest").sandbox()); | ||
jest.mock('cross-fetch', () => require('fetch-mock-jest').sandbox()); | ||
const fetchMock = cross_fetch_1.default; | ||
function getLastGraphQuery(url) { | ||
// @ts-ignore | ||
const requestBody = fetchMock.lastCall(url)[1].body; | ||
return JSON.parse(requestBody); | ||
} | ||
exports.getLastGraphQuery = getLastGraphQuery; | ||
exports.default = fetchMock; |
@@ -1,2 +0,2 @@ | ||
export declare type SchemaName = "Zora" | "Uniswap"; | ||
export declare type SchemaName = 'Zora' | 'Uniswap'; | ||
export declare function mockGraphQLQuery(url: string, mockOverrides: any, resolverOverrides?: any, schemaName?: SchemaName): void; |
@@ -18,17 +18,20 @@ "use strict"; | ||
}; | ||
async function makeQuery(mockOverrides, requestBody, resolverOverrides, schema = "Zora") { | ||
async function makeQuery(mockOverrides, requestBody, resolverOverrides, schema = 'Zora') { | ||
const mocks = { | ||
BigInt: () => "12974", | ||
BigDecimal: () => "13874.2323", | ||
Bytes: () => "ByTeSStrInG", | ||
BigInt: () => '12974', | ||
BigDecimal: () => '13874.2323', | ||
Bytes: () => 'ByTeSStrInG', | ||
// Randomly chosen by mock | ||
// breaks consistent testing | ||
ReserveAuctionBidType: () => "Final", | ||
ReserveAuctionStatus: () => "Active", | ||
Boolean: () => true, | ||
Int: () => currentID++, | ||
ReserveAuctionBidType: () => 'Final', | ||
ReserveAuctionStatus: () => 'Active', | ||
ID: () => (currentID++).toString(), | ||
User: () => ({ id: '10' }), | ||
Currency: () => ({ | ||
name: "Wrapped Ether", | ||
symbol: "WETH", | ||
name: 'Wrapped Ether', | ||
symbol: 'WETH', | ||
decimals: 18, | ||
id: "0xFACE", | ||
id: '0xFACE', | ||
}), | ||
@@ -35,0 +38,0 @@ ...mockOverrides, |
@@ -9,3 +9,3 @@ "use strict"; | ||
const src_1 = require("../src"); | ||
describe("useNFT", () => { | ||
describe('useNFT', () => { | ||
beforeEach(() => { | ||
@@ -16,8 +16,8 @@ setupFetchMock_1.default.reset(); | ||
const MEDIA_MOCK = { | ||
id: "2974", | ||
contentURI: "https://zora.co/content", | ||
metadataURI: "https://zora.co/content", | ||
id: '2974', | ||
contentURI: 'https://zora.co/content', | ||
metadataURI: 'https://zora.co/content', | ||
currentBids: [ | ||
{ | ||
amount: "10000", | ||
amount: '10000', | ||
bidder: { id: 10 }, | ||
@@ -27,13 +27,15 @@ }, | ||
}; | ||
it("loads an nft currently in an auction", async () => { | ||
const RESERVE_AUCTION_MOCK = { | ||
tokenId: 2974, | ||
status: 'Active', | ||
curatorFeePercentage: 100, | ||
approved: true, | ||
}; | ||
it('loads an nft currently in an auction', async () => { | ||
const mockOverrides = { | ||
Media: () => MEDIA_MOCK, | ||
ReserveAuction: () => ({ | ||
tokenId: "2974", | ||
status: "Active", | ||
reservePrice: "1000000", | ||
}), | ||
ReserveAuction: () => RESERVE_AUCTION_MOCK, | ||
}; | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT("2974")); | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT('2974')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -44,20 +46,16 @@ expect(result.current.error).toBeUndefined(); | ||
}); | ||
it("correctly loads auction information from uniswap", async () => { | ||
it('correctly loads auction information from uniswap', async () => { | ||
const mockZoraOverrides = { | ||
Media: () => MEDIA_MOCK, | ||
ReserveAuction: () => ({ | ||
tokenId: "2974", | ||
status: "Active", | ||
reservePrice: "1000000", | ||
}), | ||
ReserveAuction: () => RESERVE_AUCTION_MOCK, | ||
}; | ||
const mockUniswapOverrides = { | ||
Token: () => ({ | ||
id: "0xFACE", | ||
id: '0xFACE', | ||
decimals: 18, | ||
}), | ||
}; | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2", mockUniswapOverrides, {}, "Uniswap"); | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", mockZoraOverrides, {}, "Zora"); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT("2974", true)); | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', mockUniswapOverrides, {}, 'Uniswap'); | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', mockZoraOverrides, {}, 'Zora'); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT('2974', true)); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -72,10 +70,10 @@ expect(result.current.error).toBeUndefined(); | ||
}); | ||
it("loads an NFT not in an auction with bids", async () => { | ||
it('loads an NFT not in an auction with bids', async () => { | ||
const mockOverrides = { | ||
Media: () => MEDIA_MOCK, | ||
// make an invalid reserve auction record to not be picked up by the fetch API | ||
ReserveAuction: () => ({ tokenId: "-1" }), | ||
ReserveAuction: () => ({ ...RESERVE_AUCTION_MOCK, tokenId: '-1' }), | ||
}; | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT("2974")); | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT('2974')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -86,11 +84,11 @@ expect(result.current.error).toBeUndefined(); | ||
}); | ||
it("shows an error when an NFT cannot be loaded", async () => { | ||
setupFetchMock_1.default.post("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", "server failure", { response: { status: 500 } }); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT("2974")); | ||
it('shows an error when an NFT cannot be loaded', async () => { | ||
setupFetchMock_1.default.post('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', 'server failure', { response: { status: 500 } }); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT('2974')); | ||
await waitFor(() => result.current.loading === false); | ||
expect(result.current.data).toBeUndefined(); | ||
expect(result.current.error).toEqual("RequestError: Request Status = 500"); | ||
expect(result.current.error).toEqual('RequestError: Request Status = 500'); | ||
expect(result.current.loading).toBeFalsy(); | ||
}); | ||
it("loads an NFT with no bids and no auction", async () => { | ||
it('loads an NFT with no bids and no auction', async () => { | ||
const mediaWithNoBids = { ...MEDIA_MOCK, currentBids: [] }; | ||
@@ -100,6 +98,6 @@ const mockOverrides = { | ||
// make an invalid reserve auction record to not be picked up by the fetch API | ||
ReserveAuction: () => ({ tokenId: "-1" }), | ||
ReserveAuction: () => ({ ...RESERVE_AUCTION_MOCK, tokenId: '-1' }), | ||
}; | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT("2974")); | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', mockOverrides); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFT('2974')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -110,7 +108,7 @@ expect(result.current.error).toBeUndefined(); | ||
}); | ||
it("correctly loads multiple perpetual bid NFTs", async () => { | ||
it('correctly loads multiple perpetual bid NFTs', async () => { | ||
function useMultipleNFTHooks() { | ||
return [src_1.useNFT("1"), src_1.useNFT("2")]; | ||
return [src_1.useNFT('1'), src_1.useNFT('2')]; | ||
} | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", {}, (store) => { | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', {}, (store) => { | ||
return { | ||
@@ -120,3 +118,3 @@ Query: { | ||
// Fix returning ID for each record with multiple records. | ||
return [store.get("Media", "1"), store.get("Media", "2")]; | ||
return [store.get('Media', '1'), store.get('Media', '2')]; | ||
}, | ||
@@ -135,7 +133,7 @@ }, | ||
}); | ||
it("caches multiple NFTs being loaded", async () => { | ||
it('caches multiple NFTs being loaded', async () => { | ||
function useMultipleNFTHooks() { | ||
return [src_1.useNFT("1"), src_1.useNFT("2")]; | ||
return [src_1.useNFT('1'), src_1.useNFT('2')]; | ||
} | ||
setupZoraGQLMock_1.mockGraphQLQuery("https://api.thegraph.com/subgraphs/name/ourzora/zora-v1", {}, (store) => { | ||
setupZoraGQLMock_1.mockGraphQLQuery('https://api.thegraph.com/subgraphs/name/ourzora/zora-v1', {}, (store) => { | ||
return { | ||
@@ -145,3 +143,3 @@ Query: { | ||
// Fix returning ID for each record with multiple records. | ||
return [store.get("Media", "1"), store.get("Media", "2")]; | ||
return [store.get('Media', '1'), store.get('Media', '2')]; | ||
}, | ||
@@ -148,0 +146,0 @@ }, |
@@ -7,9 +7,9 @@ "use strict"; | ||
const src_1 = require("../src"); | ||
describe("useNFTContent", () => { | ||
describe('useNFTContent', () => { | ||
afterEach(() => { | ||
setupFetchMock_1.default.reset(); | ||
}); | ||
it("loads text content for NFT from server", async () => { | ||
setupFetchMock_1.default.get("https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", "this is plain text"); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent("https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", "text/plain")); | ||
it('loads text content for NFT from server', async () => { | ||
setupFetchMock_1.default.get('https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', 'this is plain text'); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent('https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', 'text/plain')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -19,9 +19,9 @@ expect(result.current.error).toBeUndefined(); | ||
expect(result.current.content).toEqual({ | ||
type: "text", | ||
mimeType: "text/plain", | ||
text: "this is plain text", | ||
type: 'text', | ||
mimeType: 'text/plain', | ||
text: 'this is plain text', | ||
}); | ||
}); | ||
it("has error fetching content", async () => { | ||
setupFetchMock_1.default.get("https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", "Not Found", { | ||
it('has error fetching content', async () => { | ||
setupFetchMock_1.default.get('https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', 'Not Found', { | ||
response: { | ||
@@ -31,3 +31,3 @@ status: 404, | ||
}); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent("https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", "text/plain")); | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent('https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', 'text/plain')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -38,4 +38,4 @@ expect(result.current.error).toEqual('RequestError: Issue fetching IPFS data'); | ||
}); | ||
it("returns reference URI to user", async () => { | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent("https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", "image/gif")); | ||
it('returns reference URI to user', async () => { | ||
const { waitFor, result } = react_hooks_1.renderHook(() => src_1.useNFTContent('https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', 'image/gif')); | ||
await waitFor(() => result.current.loading === false); | ||
@@ -45,7 +45,7 @@ expect(result.current.error).toBeUndefined(); | ||
expect(result.current.content).toEqual({ | ||
mimeType: "image/gif", | ||
mimeType: 'image/gif', | ||
type: 'uri', | ||
uri: "https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE", | ||
uri: 'https://ipfs.io/ipfs/IPFS_SHA_EXAMPLE', | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "@zoralabs/nft-hooks", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Generic Rendering Component for zNFTs", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/our-zora/nft-hooks", |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
290883
3.6%60
7.14%6758
3.67%