diff --git a/src/backends/NFTInterface.ts b/src/backends/NFTInterface.ts index 396deec..7c72876 100644 --- a/src/backends/NFTInterface.ts +++ b/src/backends/NFTInterface.ts @@ -2,6 +2,12 @@ export enum KNOWN_CONTRACTS { ZORA = 'zora', } +export enum MARKET_TYPES { + AUCTION = 'Auction', + FIXED_PRICE = 'FixedPrice', + EDITION = 'Edition', +} + type Nullable = T | null; export type ETHAddress = string; @@ -29,6 +35,12 @@ export type AuctionBidEvent = { created: TimedAction; }; +export type EditionPurchaseEvent = { + buyer: string; + price?: CurrencyValue; + purchasedAt: TimedAction; +}; + export type AuctionLike = { winner?: string; endsAt?: TimedAction; @@ -38,14 +50,22 @@ export type AuctionLike = { // current bid is duplicated within bids bids: AuctionBidEvent[]; source: 'ZoraReserveV0' | 'OpenseaEnglish'; - type: 'Auction'; + type: MARKET_TYPES.AUCTION; } & MarketInfo; export type FixedPriceLike = { side: 'ask' | 'offer'; expires?: number; source: 'ZNFTPerpetual' | 'ZoraAskV1' | 'ZoraAskV1Event' | 'OpenseaFixed'; - type: 'FixedPrice'; + type: MARKET_TYPES.FIXED_PRICE; +} & MarketInfo; + +export type EditionLike = { + totalSupply: number; + editionSize: number; + purchases: EditionPurchaseEvent[]; + source: 'Custom' | 'ZoraEditions'; + type: MARKET_TYPES.EDITION; } & MarketInfo; export type MarketInfoStatus = @@ -70,7 +90,7 @@ type MarketInfo = { cancelledAt?: TimedAction; }; -export type MarketModule = AuctionLike | FixedPriceLike; +export type MarketModule = AuctionLike | FixedPriceLike | EditionLike; export type TokenTransferEventType = 'mint' | 'burn' | 'transfer' | 'sale'; diff --git a/src/backends/zora-graph/GraphAuctionDataSource.ts b/src/backends/zora-graph/GraphAuctionDataSource.ts index b97699c..9f5b918 100644 --- a/src/backends/zora-graph/GraphAuctionDataSource.ts +++ b/src/backends/zora-graph/GraphAuctionDataSource.ts @@ -4,7 +4,7 @@ import { RequestError } from '../..'; import { NetworkIDs } from '../../constants/networks'; import { THEGRAPH_API_URL_BY_NETWORK } from '../../constants/urls'; import { FetchWithTimeout } from '../../fetcher/FetchWithTimeout'; -import type { AuctionBidEvent, AuctionLike, NFTObject } from '../NFTInterface'; +import { AuctionBidEvent, AuctionLike, MARKET_TYPES, NFTObject } from '../NFTInterface'; import { GetAllAuctionsQuery, GetAuctionByMediaQuery, @@ -149,7 +149,7 @@ export class GraphAuctionDataSource implements GraphAuctionInterface { status: getStatus(), amount: getAmount(), raw: response, - type: 'Auction', + type: MARKET_TYPES.AUCTION, createdBy: response.curator.id, createdAt: { timestamp: response.createdAtTimestamp, diff --git a/src/backends/zora-indexer-v1/ZoraIndexerV1DataSource.ts b/src/backends/zora-indexer-v1/ZoraIndexerV1DataSource.ts index 7d65da1..17a20ad 100644 --- a/src/backends/zora-indexer-v1/ZoraIndexerV1DataSource.ts +++ b/src/backends/zora-indexer-v1/ZoraIndexerV1DataSource.ts @@ -25,6 +25,7 @@ import { EventType, FixedPriceLike, MarketInfoStatus, + MARKET_TYPES, MetadataAttributeType, NFTObject, TokenMarketEvent, @@ -131,7 +132,7 @@ function extractAsk(ask: V3AskPartFragment): FixedPriceLike { // currency.decimals / currency.name / currency.symbol }, side: 'ask', - type: 'FixedPrice', + type: MARKET_TYPES.FIXED_PRICE, cancelledAt: undefined, createdAt: { timestamp: dateToUnix(created.blockTimestamp)!, @@ -201,7 +202,7 @@ function extractAskEvents(askEvents: V3EventPartFragment[]): TokenMarketEvent[] // currency.decimals / currency.name / currency.symbol }, side: 'ask', - type: 'FixedPrice', + type: MARKET_TYPES.FIXED_PRICE, cancelledAt: status === 'cancelled' ? { @@ -293,7 +294,7 @@ function extractAuction(auction: IndexerAuctionPartFragment) { transactionHash: auction.createdEvent!.transactionHash, }, createdBy: auction.tokenOwner || undefined, - type: 'Auction', + type: MARKET_TYPES.AUCTION, finishedAt: auction.endedEvent ? { timestamp: dateToUnix(auction.endedEvent.blockTimestamp)!,