This commit is contained in:
alexcos20 2023-07-29 19:58:39 +03:00
parent de36363438
commit 6a78790bd4
2 changed files with 20 additions and 20 deletions

View File

@ -15,11 +15,12 @@ import { getUser } from './utils/userUtils'
import {
getToken,
getNftToken,
getPredictContract,
getErc20TemplateId
getErc20TemplateId,
getPredictContract
} from './utils/tokenUtils'
import { BigInt } from '@graphprotocol/graph-ts'
import { addDatatoken } from './utils/globalUtils'
export function handleNftCreated(event: NFTCreated): void {
// const nft = new Nft(event.params.newTokenAddress.toHexString())
const nft = getNftToken(event.params.newTokenAddress)
@ -37,7 +38,6 @@ export function handleNftCreated(event: NFTCreated): void {
nft.eventIndex = event.logIndex.toI32()
nft.transferable = event.params.transferable
nft.template = event.params.templateAddress.toHexString()
nft.save()
}
@ -62,7 +62,7 @@ export function handleNewToken(event: TokenCreated): void {
token.templateId = getErc20TemplateId(event.params.templateAddress)
token.save()
addDatatoken()
if (token.templateId == BigInt.fromString('3')) {
if (token.templateId === BigInt.fromString('3')) {
factoryERC20Template3.create(event.params.newTokenAddress)
const predictContract = getPredictContract(event.params.newTokenAddress)
predictContract.timestamp = event.block.timestamp.toI32()

View File

@ -114,6 +114,22 @@ export function getUSDValue(
return BigDecimal.zero()
}
export function getErc721TemplateId(address: Address): BigInt {
const template = Erc721Template.load(address.toHexString())
if (template) {
return template.templateId
}
return BigInt.zero()
}
export function getErc20TemplateId(address: Address): BigInt {
const template = Erc20Template.load(address.toHexString())
if (template) {
return template.templateId
}
return BigInt.zero()
}
export function createPredictContract(address: Address): PredictContract {
const predictContract = new PredictContract(address.toHexString())
const token = getToken(address, true)
@ -137,19 +153,3 @@ export function getPredictContract(address: Address): PredictContract {
}
return newPredictContract
}
export function getErc721TemplateId(address: Address): BigInt {
const template = Erc721Template.load(address.toHexString())
if (template) {
return template.templateId
}
return BigInt.zero()
}
export function getErc20TemplateId(address: Address): BigInt {
const template = Erc20Template.load(address.toHexString())
if (template) {
return template.templateId
}
return BigInt.zero()
}