Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcos20 committed Jul 29, 2023
1 parent de36363 commit 6a78790
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/mappings/erc721Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}

Expand All @@ -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()
Expand Down
32 changes: 16 additions & 16 deletions src/mappings/utils/tokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}

0 comments on commit 6a78790

Please sign in to comment.