From 2a7842aa9f53a0e475a5427159d4ea2236508ee5 Mon Sep 17 00:00:00 2001 From: Ignacio Mazzara Date: Fri, 9 Jul 2021 10:01:08 -0300 Subject: [PATCH] feat: add tokenId to orders --- indexer/README.md | 6 ++++++ indexer/schema.graphql | 2 ++ indexer/src/handlers/bid.ts | 1 + indexer/src/handlers/marketplace.ts | 1 + 4 files changed, 10 insertions(+) diff --git a/indexer/README.md b/indexer/README.md index d7a57acb74..904b4aeb05 100644 --- a/indexer/README.md +++ b/indexer/README.md @@ -13,6 +13,12 @@ npm run build npm run deploy -- --network mainnet ``` +If a new collection in Ethereum is added you will need to add it as following + +``` +npx ts-node scripts/importWearableCollection.ts --collection ../../wearable-api/data/collections/{collection_name}/index.json > src/data/wearables/{collection_name}.ts +``` + checkout the docs https://thegraph.com/docs/quick-start ### Queries diff --git a/indexer/schema.graphql b/indexer/schema.graphql index 89ceecb519..e892017e4e 100644 --- a/indexer/schema.graphql +++ b/indexer/schema.graphql @@ -35,6 +35,7 @@ type Order @entity { category: Category! nft: NFT nftAddress: Bytes! + tokenId: BigInt! txHash: Bytes! owner: Bytes! buyer: Bytes @@ -55,6 +56,7 @@ type Bid @entity { category: Category! nft: NFT nftAddress: Bytes! + tokenId: BigInt! bidder: Bytes seller: Bytes price: BigInt! diff --git a/indexer/src/handlers/bid.ts b/indexer/src/handlers/bid.ts index d397928992..a1a6f7534f 100644 --- a/indexer/src/handlers/bid.ts +++ b/indexer/src/handlers/bid.ts @@ -33,6 +33,7 @@ export function handleBidCreated(event: BidCreated): void { bid.bidder = event.params._bidder bid.price = event.params._price bid.fingerprint = event.params._fingerprint + bid.tokenId = event.params._tokenId bid.blockchainId = event.params._id.toHexString() bid.blockNumber = event.block.number bid.expiresAt = event.params._expiresAt.times(BigInt.fromI32(1000)) diff --git a/indexer/src/handlers/marketplace.ts b/indexer/src/handlers/marketplace.ts index 38c03be8d1..15b9e8d878 100644 --- a/indexer/src/handlers/marketplace.ts +++ b/indexer/src/handlers/marketplace.ts @@ -31,6 +31,7 @@ export function handleOrderCreated(event: OrderCreated): void { order.category = category order.nft = nftId order.nftAddress = event.params.nftAddress + order.tokenId = event.params.assetId order.txHash = event.transaction.hash order.owner = event.params.seller order.price = event.params.priceInWei