mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
Tracking nft transferHistory
This commit is contained in:
parent
1bf645541f
commit
0e0bdff980
@ -582,7 +582,7 @@ type NftTransferHistory @entity {
|
|||||||
oldOwner: User!
|
oldOwner: User!
|
||||||
newOwner: User!
|
newOwner: User!
|
||||||
txId: String
|
txId: String
|
||||||
timestamp: BigInt!
|
timestamp: Int!
|
||||||
block: Int!
|
block: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ export function handleNftCreated(event: NFTCreated): void {
|
|||||||
nft.tx = event.transaction.hash.toHex()
|
nft.tx = event.transaction.hash.toHex()
|
||||||
nft.block = event.block.number.toI32()
|
nft.block = event.block.number.toI32()
|
||||||
nft.transferable = event.params.transferable
|
nft.transferable = event.params.transferable
|
||||||
|
nft.transferHistory = []
|
||||||
|
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Nft, NftUpdate, NftData } from '../@types/schema'
|
import { Nft, NftUpdate, NftData, NftTransferHistory } from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
MetadataCreated,
|
MetadataCreated,
|
||||||
MetadataState,
|
MetadataState,
|
||||||
@ -256,8 +256,21 @@ export function handleCleanedPermissions(event: CleanedPermissions): void {
|
|||||||
export function handleNftTransferred(event: Transfer): void {
|
export function handleNftTransferred(event: Transfer): void {
|
||||||
const id = event.address.toHex()
|
const id = event.address.toHex()
|
||||||
const nft = getNftTokenWithID(id)
|
const nft = getNftTokenWithID(id)
|
||||||
|
const oldOwner = nft.owner
|
||||||
const newOwner = getUser(event.params.to.toHexString())
|
const newOwner = getUser(event.params.to.toHexString())
|
||||||
nft.owner = newOwner.id
|
nft.owner = newOwner.id
|
||||||
|
const transferId = `${nft.address}-${id}-${event.logIndex}`
|
||||||
|
const newTransfer = new NftTransferHistory(transferId)
|
||||||
|
newTransfer.nft = nft.id
|
||||||
|
newTransfer.oldOwner = oldOwner
|
||||||
|
newTransfer.newOwner = newOwner.id
|
||||||
|
newTransfer.txId = id
|
||||||
|
newTransfer.timestamp = event.block.timestamp.toI32()
|
||||||
|
newTransfer.block = event.block.number.toI32()
|
||||||
|
newTransfer.save()
|
||||||
|
if (nft.transferHistory && typeof newTransfer.id === 'string') {
|
||||||
|
nft.transferHistory!.push(newTransfer.id)
|
||||||
|
}
|
||||||
nft.save()
|
nft.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user