add nft.orderCount (#332)

This commit is contained in:
Alex Coseru 2022-02-17 14:00:54 +02:00 committed by GitHub
parent f3b501b728
commit cd27a2432d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -100,6 +100,9 @@ type Nft @entity{
tx: String!
"block number when it was created"
block: Int
"number of orders executed for all underlying datatokens"
orderCount: BigInt!
}
type Pool @entity {

View File

@ -1,4 +1,4 @@
import { Order } from '../@types/schema'
import { Order, Nft } from '../@types/schema'
import { BigInt } from '@graphprotocol/graph-ts'
import {
NewPaymentCollector,
@ -60,6 +60,13 @@ export function handleOrderStarted(event: OrderStarted): void {
order.save()
token.save()
addOrder()
if (token.nft) {
const nft = Nft.load(token.nft as string) as Nft
if (nft) {
nft.orderCount = nft.orderCount.plus(integer.ONE)
nft.save()
}
}
}
export function handleNewPaymentCollector(event: NewPaymentCollector): void {}

View File

@ -17,6 +17,7 @@ export function handleCreated(event: MetadataCreated): void {
nft.assetState = event.params.state
nft.providerUrl = event.params.decryptorUrl.toString()
const nftUpdate = new NftUpdate(
getId(event.transaction.hash.toHex(), nftAddress)
)