mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
nftupdate
This commit is contained in:
parent
1868a6219c
commit
89b494c765
@ -39,7 +39,7 @@ type Token @entity {
|
|||||||
createdTimestamp: Int
|
createdTimestamp: Int
|
||||||
|
|
||||||
"datatoken creation transaction id"
|
"datatoken creation transaction id"
|
||||||
tx: Bytes
|
tx: String!
|
||||||
|
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
@ -84,7 +84,7 @@ type Nft @entity{
|
|||||||
"block time nft was created"
|
"block time nft was created"
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
"nft creation transaction id"
|
"nft creation transaction id"
|
||||||
tx: Bytes
|
tx: String!
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ type Pool @entity {
|
|||||||
"block time when pool was created"
|
"block time when pool was created"
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
"pool creation transaction id"
|
"pool creation transaction id"
|
||||||
tx: Bytes
|
tx: String!
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ type PoolTransaction @entity {
|
|||||||
"block time when pool was created"
|
"block time when pool was created"
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
"pool creation transaction id"
|
"pool creation transaction id"
|
||||||
tx: Bytes
|
tx: String!
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ type Order @entity {
|
|||||||
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
|
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
|
||||||
|
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes
|
tx: String!
|
||||||
block: Int!
|
block: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ type TokenTransaction @entity {
|
|||||||
gasUsed: BigDecimal!
|
gasUsed: BigDecimal!
|
||||||
gasPrice: BigDecimal!
|
gasPrice: BigDecimal!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes!
|
tx: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
type User @entity {
|
type User @entity {
|
||||||
@ -303,7 +303,7 @@ type FixedRateExchange @entity {
|
|||||||
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
||||||
|
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes
|
tx: String!
|
||||||
block: Int!
|
block: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ type FixedRateExchangeUpdate @entity {
|
|||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes!
|
tx: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
type FixedRateExchangeSwap @entity {
|
type FixedRateExchangeSwap @entity {
|
||||||
@ -333,7 +333,7 @@ type FixedRateExchangeSwap @entity {
|
|||||||
dataTokenAmount: BigDecimal!
|
dataTokenAmount: BigDecimal!
|
||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes!
|
tx: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ type DispenserTransaction @entity {
|
|||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: Int!
|
||||||
tx: Bytes!
|
tx: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
type PoolSnapshot @entity {
|
type PoolSnapshot @entity {
|
||||||
@ -410,9 +410,17 @@ type GlobalStats @entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum NftUpdateType {
|
||||||
|
METADATA_CREATED,
|
||||||
|
METADATA_UPDATED,
|
||||||
|
STATE_UPDATED,
|
||||||
|
TOKENURI_UPDATED
|
||||||
|
}
|
||||||
|
|
||||||
type NftUpdate @entity {
|
type NftUpdate @entity {
|
||||||
id: ID! # update tx + nft address
|
id: ID! # update tx + nft address
|
||||||
datatoken: Nft!
|
|
||||||
|
nft: Nft!
|
||||||
|
|
||||||
"user that made the update"
|
"user that made the update"
|
||||||
userAddress: String!
|
userAddress: String!
|
||||||
@ -420,7 +428,10 @@ type NftUpdate @entity {
|
|||||||
"state of the asset in this update"
|
"state of the asset in this update"
|
||||||
assetState: Int!
|
assetState: Int!
|
||||||
|
|
||||||
|
"type of the update: metadata created, metadata update, state update, token uri update"
|
||||||
|
type: NftUpdateType!
|
||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: Bytes!
|
tx: String!
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ export function handleTokensDispensed(event: TokensDispensed): void {
|
|||||||
dispenserTransaction.user = user.id
|
dispenserTransaction.user = user.id
|
||||||
|
|
||||||
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
||||||
dispenserTransaction.tx = event.transaction.hash
|
dispenserTransaction.tx = event.transaction.hash.toHex()
|
||||||
dispenserTransaction.block = event.block.number.toI32()
|
dispenserTransaction.block = event.block.number.toI32()
|
||||||
dispenserTransaction.save()
|
dispenserTransaction.save()
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ export function handleOrderStarted(event: OrderStarted): void {
|
|||||||
order.consumerMarket = consumeMarket.id
|
order.consumerMarket = consumeMarket.id
|
||||||
|
|
||||||
order.createdTimestamp = event.block.timestamp.toI32()
|
order.createdTimestamp = event.block.timestamp.toI32()
|
||||||
order.tx = event.transaction.hash
|
order.tx = event.transaction.hash.toHex()
|
||||||
order.block = event.block.number.toI32()
|
order.block = event.block.number.toI32()
|
||||||
|
|
||||||
order.save()
|
order.save()
|
||||||
|
@ -12,7 +12,7 @@ export function handleNftCreated(event: NFTCreated): void {
|
|||||||
nft.name = event.params.tokenName
|
nft.name = event.params.tokenName
|
||||||
nft.symbol = ''
|
nft.symbol = ''
|
||||||
nft.createdTimestamp = event.block.timestamp.toI32()
|
nft.createdTimestamp = event.block.timestamp.toI32()
|
||||||
nft.tx = event.transaction.hash
|
nft.tx = event.transaction.hash.toHex()
|
||||||
nft.block = event.block.number.toI32()
|
nft.block = event.block.number.toI32()
|
||||||
|
|
||||||
nft.save()
|
nft.save()
|
||||||
@ -23,7 +23,7 @@ export function handleNewToken(event: TokenCreated): void {
|
|||||||
token.isDatatoken = true
|
token.isDatatoken = true
|
||||||
token.address = event.params.newTokenAddress.toHexString()
|
token.address = event.params.newTokenAddress.toHexString()
|
||||||
token.createdTimestamp = event.block.timestamp.toI32()
|
token.createdTimestamp = event.block.timestamp.toI32()
|
||||||
token.tx = event.transaction.hash
|
token.tx = event.transaction.hash.toHex()
|
||||||
token.block = event.block.number.toI32()
|
token.block = event.block.number.toI32()
|
||||||
|
|
||||||
token.name = event.params.name
|
token.name = event.params.name
|
||||||
|
@ -48,7 +48,7 @@ export function handleRateChange(event: ExchangeRateChanged): void {
|
|||||||
)
|
)
|
||||||
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
fixedRateExchange.price = weiToDecimal(
|
fixedRateExchange.price = weiToDecimal(
|
||||||
@ -84,7 +84,7 @@ export function handleActivated(event: ExchangeActivated): void {
|
|||||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||||
newExchangeUpdate.newActive = true
|
newExchangeUpdate.newActive = true
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
fixedRateExchange.active = true
|
fixedRateExchange.active = true
|
||||||
@ -107,7 +107,7 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
|||||||
newExchangeUpdate.newActive = false
|
newExchangeUpdate.newActive = false
|
||||||
|
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
fixedRateExchange.active = false
|
fixedRateExchange.active = false
|
||||||
@ -129,7 +129,7 @@ export function handleAllowedSwapperChanged(
|
|||||||
)
|
)
|
||||||
|
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash
|
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ export function handleSwap(event: Swapped): void {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
swap.createdTimestamp = event.block.timestamp.toI32()
|
swap.createdTimestamp = event.block.timestamp.toI32()
|
||||||
swap.tx = event.transaction.hash
|
swap.tx = event.transaction.hash.toHex()
|
||||||
swap.block = event.block.number.toI32()
|
swap.block = event.block.number.toI32()
|
||||||
|
|
||||||
swap.exchangeId = event.params.exchangeId.toHex()
|
swap.exchangeId = event.params.exchangeId.toHex()
|
||||||
|
@ -1,14 +1,104 @@
|
|||||||
|
import { Nft, NftUpdate } from '../@types/schema'
|
||||||
import {
|
import {
|
||||||
MetadataCreated,
|
MetadataCreated,
|
||||||
MetadataState,
|
MetadataState,
|
||||||
MetadataUpdated,
|
MetadataUpdated,
|
||||||
TokenURIUpdate
|
TokenURIUpdate
|
||||||
} from '../@types/templates/ERC721Template/ERC721Template'
|
} from '../@types/templates/ERC721Template/ERC721Template'
|
||||||
|
import { NftUpdateType } from './utils/constants'
|
||||||
|
|
||||||
export function handleCreated(event: MetadataCreated): void {}
|
function getId(tx: string, nftAddress: string): string {
|
||||||
|
return `${tx}-${nftAddress}`
|
||||||
|
}
|
||||||
|
|
||||||
export function handleUpdated(event: MetadataUpdated): void {}
|
export function handleCreated(event: MetadataCreated): void {
|
||||||
|
const nftAddress = event.address.toHex()
|
||||||
|
const nft = Nft.load(nftAddress)
|
||||||
|
if (!nft) return
|
||||||
|
|
||||||
export function handleState(event: MetadataState): void {}
|
nft.assetState = event.params.state
|
||||||
|
|
||||||
export function handleUriUpdate(event: TokenURIUpdate): void {}
|
const nftUpdate = new NftUpdate(
|
||||||
|
getId(event.transaction.hash.toHex(), nftAddress)
|
||||||
|
)
|
||||||
|
|
||||||
|
nftUpdate.type = NftUpdateType.METADATA_CREATED
|
||||||
|
nftUpdate.userAddress = event.params.createdBy.toHex()
|
||||||
|
nftUpdate.assetState = event.params.state
|
||||||
|
|
||||||
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
|
nftUpdate.save()
|
||||||
|
nft.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleUpdated(event: MetadataUpdated): void {
|
||||||
|
const nftAddress = event.address.toHex()
|
||||||
|
const nft = Nft.load(nftAddress)
|
||||||
|
if (!nft) return
|
||||||
|
|
||||||
|
nft.assetState = event.params.state
|
||||||
|
|
||||||
|
const nftUpdate = new NftUpdate(
|
||||||
|
getId(event.transaction.hash.toHex(), nftAddress)
|
||||||
|
)
|
||||||
|
|
||||||
|
nftUpdate.type = NftUpdateType.METADATA_UPDATED
|
||||||
|
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||||
|
nftUpdate.assetState = event.params.state
|
||||||
|
|
||||||
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
|
nftUpdate.save()
|
||||||
|
nft.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleState(event: MetadataState): void {
|
||||||
|
const nftAddress = event.address.toHex()
|
||||||
|
const nft = Nft.load(nftAddress)
|
||||||
|
if (!nft) return
|
||||||
|
|
||||||
|
nft.assetState = event.params.state
|
||||||
|
|
||||||
|
const nftUpdate = new NftUpdate(
|
||||||
|
getId(event.transaction.hash.toHex(), nftAddress)
|
||||||
|
)
|
||||||
|
|
||||||
|
nftUpdate.type = NftUpdateType.STATE_UPDATED
|
||||||
|
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||||
|
nftUpdate.assetState = event.params.state
|
||||||
|
|
||||||
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
|
nftUpdate.save()
|
||||||
|
nft.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleTokenUriUpdate(event: TokenURIUpdate): void {
|
||||||
|
const nftAddress = event.address.toHex()
|
||||||
|
const nft = Nft.load(nftAddress)
|
||||||
|
|
||||||
|
if (!nft) return
|
||||||
|
|
||||||
|
nft.tokenUri = event.params.tokenURI
|
||||||
|
|
||||||
|
const nftUpdate = new NftUpdate(
|
||||||
|
getId(event.transaction.hash.toHex(), nftAddress)
|
||||||
|
)
|
||||||
|
|
||||||
|
nftUpdate.type = NftUpdateType.TOKENURI_UPDATED
|
||||||
|
nftUpdate.userAddress = event.params.updatedBy.toHex()
|
||||||
|
|
||||||
|
nftUpdate.timestamp = event.block.timestamp.toI32()
|
||||||
|
nftUpdate.tx = event.transaction.hash.toHex()
|
||||||
|
nftUpdate.block = event.block.number.toI32()
|
||||||
|
|
||||||
|
nftUpdate.save()
|
||||||
|
nft.save()
|
||||||
|
}
|
||||||
|
@ -1,26 +1,20 @@
|
|||||||
import { BPoolCreated } from '../@types/FactoryRouter/FactoryRouter'
|
import { BPoolCreated } from '../@types/FactoryRouter/FactoryRouter'
|
||||||
import { Pool } from '../@types/schema'
|
import { Pool } from '../@types/schema'
|
||||||
import { getPoolToken } from './utils/poolUtils'
|
import { getToken } from './utils/tokenUtils'
|
||||||
|
|
||||||
export function handleNewPool(event: BPoolCreated): void {
|
export function handleNewPool(event: BPoolCreated): void {
|
||||||
const pool = new Pool(event.params.newBPoolAddress.toHex())
|
const pool = new Pool(event.params.newBPoolAddress.toHex())
|
||||||
|
|
||||||
const baseToken = getPoolToken(
|
const baseToken = getToken(event.params.basetokenAddress.toHex())
|
||||||
event.params.newBPoolAddress.toHex(),
|
|
||||||
event.params.basetokenAddress.toHex()
|
|
||||||
)
|
|
||||||
pool.baseToken = baseToken.id
|
pool.baseToken = baseToken.id
|
||||||
|
|
||||||
const datatoken = getPoolToken(
|
const datatoken = getToken(event.params.datatokenAddress.toHex())
|
||||||
event.params.newBPoolAddress.toHex(),
|
|
||||||
event.params.datatokenAddress.toHex()
|
|
||||||
)
|
|
||||||
pool.datatoken = datatoken.id
|
pool.datatoken = datatoken.id
|
||||||
|
|
||||||
pool.owner = event.params.registeredBy.toHex()
|
pool.owner = event.params.registeredBy.toHex()
|
||||||
|
|
||||||
pool.createdTimestamp = event.block.timestamp.toI32()
|
pool.createdTimestamp = event.block.timestamp.toI32()
|
||||||
pool.tx = event.transaction.hash
|
pool.tx = event.transaction.hash.toHex()
|
||||||
pool.block = event.block.number.toI32()
|
pool.block = event.block.number.toI32()
|
||||||
|
|
||||||
pool.save()
|
pool.save()
|
||||||
|
@ -25,3 +25,10 @@ export enum PoolTransactionType {
|
|||||||
SWAP = 'SWAP',
|
SWAP = 'SWAP',
|
||||||
SETUP = 'SETUP'
|
SETUP = 'SETUP'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum NftUpdateType {
|
||||||
|
METADATA_CREATED = 'METADATA_CREATED',
|
||||||
|
METADATA_UPDATED = 'METADATA_UPDATED',
|
||||||
|
STATE_UPDATED = 'STATE_UPDATED',
|
||||||
|
TOKENURI_UPDATED = 'TOKENURI_UPDATED'
|
||||||
|
}
|
||||||
|
@ -194,6 +194,6 @@ templates:
|
|||||||
- event: MetadataState(indexed address,uint8,uint256,uint256)
|
- event: MetadataState(indexed address,uint8,uint256,uint256)
|
||||||
handler: handleState
|
handler: handleState
|
||||||
- event: TokenURIUpdate(indexed address,string,uint256,uint256,uint256)
|
- event: TokenURIUpdate(indexed address,string,uint256,uint256,uint256)
|
||||||
handler: handleUriUpdate
|
handler: handleTokenUriUpdate
|
||||||
features:
|
features:
|
||||||
- nonFatalErrors
|
- nonFatalErrors
|
||||||
|
Loading…
Reference in New Issue
Block a user