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

@ -99,7 +99,10 @@ type Nft @entity{
"nft creation transaction id" "nft creation transaction id"
tx: String! tx: String!
"block number when it was created" "block number when it was created"
block: Int block: Int
"number of orders executed for all underlying datatokens"
orderCount: BigInt!
} }
type Pool @entity { 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 { BigInt } from '@graphprotocol/graph-ts'
import { import {
NewPaymentCollector, NewPaymentCollector,
@ -60,6 +60,13 @@ export function handleOrderStarted(event: OrderStarted): void {
order.save() order.save()
token.save() token.save()
addOrder() 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 {} export function handleNewPaymentCollector(event: NewPaymentCollector): void {}

View File

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