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
|
||||
|
||||
"datatoken creation transaction id"
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
@ -84,7 +84,7 @@ type Nft @entity{
|
||||
"block time nft was created"
|
||||
createdTimestamp: Int!
|
||||
"nft creation transaction id"
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
}
|
||||
@ -163,7 +163,7 @@ type Pool @entity {
|
||||
"block time when pool was created"
|
||||
createdTimestamp: Int!
|
||||
"pool creation transaction id"
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
|
||||
@ -211,7 +211,7 @@ type PoolTransaction @entity {
|
||||
"block time when pool was created"
|
||||
timestamp: Int!
|
||||
"pool creation transaction id"
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
|
||||
@ -253,7 +253,7 @@ type Order @entity {
|
||||
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
|
||||
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ type TokenTransaction @entity {
|
||||
gasUsed: BigDecimal!
|
||||
gasPrice: BigDecimal!
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes!
|
||||
tx: String!
|
||||
}
|
||||
|
||||
type User @entity {
|
||||
@ -303,7 +303,7 @@ type FixedRateExchange @entity {
|
||||
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
||||
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes
|
||||
tx: String!
|
||||
block: Int!
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ type FixedRateExchangeUpdate @entity {
|
||||
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes!
|
||||
tx: String!
|
||||
}
|
||||
|
||||
type FixedRateExchangeSwap @entity {
|
||||
@ -333,7 +333,7 @@ type FixedRateExchangeSwap @entity {
|
||||
dataTokenAmount: BigDecimal!
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes!
|
||||
tx: String!
|
||||
}
|
||||
|
||||
|
||||
@ -364,7 +364,7 @@ type DispenserTransaction @entity {
|
||||
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
tx: Bytes!
|
||||
tx: String!
|
||||
}
|
||||
|
||||
type PoolSnapshot @entity {
|
||||
@ -402,25 +402,36 @@ type GlobalStats @entity {
|
||||
orderCount: BigInt
|
||||
|
||||
"number of pools for all factories"
|
||||
poolCount: Int!
|
||||
poolCount: Int!
|
||||
"number of finalized pools for all factories"
|
||||
finalizedPoolCount: Int!
|
||||
finalizedPoolCount: Int!
|
||||
"probably remove due to inconsistencies and imposibility to calculate"
|
||||
totalOrderVolume: BigDecimal
|
||||
totalOrderVolume: BigDecimal
|
||||
}
|
||||
|
||||
|
||||
enum NftUpdateType {
|
||||
METADATA_CREATED,
|
||||
METADATA_UPDATED,
|
||||
STATE_UPDATED,
|
||||
TOKENURI_UPDATED
|
||||
}
|
||||
|
||||
type NftUpdate @entity {
|
||||
id: ID! # update tx + nft address
|
||||
datatoken: Nft!
|
||||
|
||||
nft: Nft!
|
||||
|
||||
"user that made the update"
|
||||
userAddress: String!
|
||||
|
||||
"state of the asset in this update"
|
||||
"state of the asset in this update"
|
||||
assetState: Int!
|
||||
|
||||
"type of the update: metadata created, metadata update, state update, token uri update"
|
||||
type: NftUpdateType!
|
||||
|
||||
block: Int!
|
||||
timestamp: Int!
|
||||
tx: Bytes!
|
||||
tx: String!
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export function handleTokensDispensed(event: TokensDispensed): void {
|
||||
dispenserTransaction.user = user.id
|
||||
|
||||
dispenserTransaction.createdTimestamp = event.block.timestamp.toI32()
|
||||
dispenserTransaction.tx = event.transaction.hash
|
||||
dispenserTransaction.tx = event.transaction.hash.toHex()
|
||||
dispenserTransaction.block = event.block.number.toI32()
|
||||
dispenserTransaction.save()
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ export function handleOrderStarted(event: OrderStarted): void {
|
||||
order.consumerMarket = consumeMarket.id
|
||||
|
||||
order.createdTimestamp = event.block.timestamp.toI32()
|
||||
order.tx = event.transaction.hash
|
||||
order.tx = event.transaction.hash.toHex()
|
||||
order.block = event.block.number.toI32()
|
||||
|
||||
order.save()
|
||||
|
@ -12,7 +12,7 @@ export function handleNftCreated(event: NFTCreated): void {
|
||||
nft.name = event.params.tokenName
|
||||
nft.symbol = ''
|
||||
nft.createdTimestamp = event.block.timestamp.toI32()
|
||||
nft.tx = event.transaction.hash
|
||||
nft.tx = event.transaction.hash.toHex()
|
||||
nft.block = event.block.number.toI32()
|
||||
|
||||
nft.save()
|
||||
@ -23,7 +23,7 @@ export function handleNewToken(event: TokenCreated): void {
|
||||
token.isDatatoken = true
|
||||
token.address = event.params.newTokenAddress.toHexString()
|
||||
token.createdTimestamp = event.block.timestamp.toI32()
|
||||
token.tx = event.transaction.hash
|
||||
token.tx = event.transaction.hash.toHex()
|
||||
token.block = event.block.number.toI32()
|
||||
|
||||
token.name = event.params.name
|
||||
|
@ -48,7 +48,7 @@ export function handleRateChange(event: ExchangeRateChanged): void {
|
||||
)
|
||||
newExchangeUpdate.oldPrice = fixedRateExchange.price
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
|
||||
fixedRateExchange.price = weiToDecimal(
|
||||
@ -84,7 +84,7 @@ export function handleActivated(event: ExchangeActivated): void {
|
||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||
newExchangeUpdate.newActive = true
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
|
||||
fixedRateExchange.active = true
|
||||
@ -107,7 +107,7 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
||||
newExchangeUpdate.newActive = false
|
||||
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
|
||||
fixedRateExchange.active = false
|
||||
@ -129,7 +129,7 @@ export function handleAllowedSwapperChanged(
|
||||
)
|
||||
|
||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||
newExchangeUpdate.tx = event.transaction.hash
|
||||
newExchangeUpdate.tx = event.transaction.hash.toHex()
|
||||
newExchangeUpdate.block = event.block.number.toI32()
|
||||
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
|
||||
|
||||
@ -159,7 +159,7 @@ export function handleSwap(event: Swapped): void {
|
||||
)
|
||||
)
|
||||
swap.createdTimestamp = event.block.timestamp.toI32()
|
||||
swap.tx = event.transaction.hash
|
||||
swap.tx = event.transaction.hash.toHex()
|
||||
swap.block = event.block.number.toI32()
|
||||
|
||||
swap.exchangeId = event.params.exchangeId.toHex()
|
||||
|
@ -1,14 +1,104 @@
|
||||
import { Nft, NftUpdate } from '../@types/schema'
|
||||
import {
|
||||
MetadataCreated,
|
||||
MetadataState,
|
||||
MetadataUpdated,
|
||||
TokenURIUpdate
|
||||
} 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 { Pool } from '../@types/schema'
|
||||
import { getPoolToken } from './utils/poolUtils'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
|
||||
export function handleNewPool(event: BPoolCreated): void {
|
||||
const pool = new Pool(event.params.newBPoolAddress.toHex())
|
||||
|
||||
const baseToken = getPoolToken(
|
||||
event.params.newBPoolAddress.toHex(),
|
||||
event.params.basetokenAddress.toHex()
|
||||
)
|
||||
const baseToken = getToken(event.params.basetokenAddress.toHex())
|
||||
pool.baseToken = baseToken.id
|
||||
|
||||
const datatoken = getPoolToken(
|
||||
event.params.newBPoolAddress.toHex(),
|
||||
event.params.datatokenAddress.toHex()
|
||||
)
|
||||
const datatoken = getToken(event.params.datatokenAddress.toHex())
|
||||
pool.datatoken = datatoken.id
|
||||
|
||||
pool.owner = event.params.registeredBy.toHex()
|
||||
|
||||
pool.createdTimestamp = event.block.timestamp.toI32()
|
||||
pool.tx = event.transaction.hash
|
||||
pool.tx = event.transaction.hash.toHex()
|
||||
pool.block = event.block.number.toI32()
|
||||
|
||||
pool.save()
|
||||
|
@ -25,3 +25,10 @@ export enum PoolTransactionType {
|
||||
SWAP = 'SWAP',
|
||||
SETUP = 'SETUP'
|
||||
}
|
||||
|
||||
export enum NftUpdateType {
|
||||
METADATA_CREATED = 'METADATA_CREATED',
|
||||
METADATA_UPDATED = 'METADATA_UPDATED',
|
||||
STATE_UPDATED = 'STATE_UPDATED',
|
||||
TOKENURI_UPDATED = 'TOKENURI_UPDATED'
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ templates:
|
||||
- event: PublishMarketFees(indexed address,indexed address,uint256)
|
||||
handler: handlePublishMarketFees
|
||||
- event: ConsumeMarketFees(indexed address,indexed address,uint256)
|
||||
handler: handleConsumeMarketFees
|
||||
handler: handleConsumeMarketFees
|
||||
- kind: ethereum/contract
|
||||
name: BFactory
|
||||
network: barge
|
||||
@ -194,6 +194,6 @@ templates:
|
||||
- event: MetadataState(indexed address,uint8,uint256,uint256)
|
||||
handler: handleState
|
||||
- event: TokenURIUpdate(indexed address,string,uint256,uint256,uint256)
|
||||
handler: handleUriUpdate
|
||||
handler: handleTokenUriUpdate
|
||||
features:
|
||||
- nonFatalErrors
|
||||
|
Loading…
Reference in New Issue
Block a user