fixes
This commit is contained in:
parent
4938756417
commit
6779057c12
|
@ -684,7 +684,7 @@ type PredictPrediction @entity{
|
|||
}
|
||||
|
||||
|
||||
type PredictTrueVals @entity{
|
||||
type PredictTrueVal @entity{
|
||||
"id = {contract address}-{slot}"
|
||||
id: ID!
|
||||
slot: PredictSlot!
|
||||
|
@ -715,7 +715,7 @@ type PredictSlot @entity{
|
|||
predictContract: PredictContract!
|
||||
slot: BigInt!
|
||||
predictions:[PredictPrediction!] @derivedFrom(field: "slot")
|
||||
trueValues: [PredictTrueVals!] @derivedFrom(field: "slot")
|
||||
trueValues: [PredictTrueVal!] @derivedFrom(field: "slot")
|
||||
revenue: BigDecimal!
|
||||
revenues: [PredictionRevenue!] @derivedFrom(field: "slot")
|
||||
status: PredictSlotStatus!
|
||||
|
|
|
@ -2,7 +2,7 @@ import {
|
|||
PredictSubscription,
|
||||
PredictPayout,
|
||||
PredictPrediction,
|
||||
PredictTrueVals,
|
||||
PredictTrueVal,
|
||||
PredictSlot,
|
||||
PredictSettingUpdate,
|
||||
PredictionRevenue
|
||||
|
@ -87,6 +87,7 @@ export function handlePredictionPayout(event: PredictionPayout): void {
|
|||
if (!predictPrediction) return
|
||||
const predictionPayout = new PredictPayout(predictionId)
|
||||
predictionPayout.prediction = predictPrediction.id
|
||||
|
||||
let decimals = 18
|
||||
const predictContract = getPredictContract(event.address)
|
||||
if (predictContract.stakeToken) {
|
||||
|
@ -111,6 +112,9 @@ export function handlePredictionPayout(event: PredictionPayout): void {
|
|||
predictionPayout.eventIndex = event.logIndex.toI32()
|
||||
predictionPayout.timestamp = event.block.timestamp.toI32()
|
||||
predictionPayout.save()
|
||||
|
||||
predictPrediction.payout = predictionPayout.id
|
||||
predictPrediction.save()
|
||||
}
|
||||
|
||||
export function handleNewSubscription(event: NewSubscription): void {
|
||||
|
@ -138,7 +142,8 @@ export function handleTruevalSubmitted(event: TruevalSubmitted): void {
|
|||
event.address.toHexString(),
|
||||
event.params.slot
|
||||
)
|
||||
const newPredictTrueVals = new PredictTrueVals(predictSlot.id) // they share the same id
|
||||
const id = event.address.toHexString() + '-' + event.params.slot.toString()
|
||||
const newPredictTrueVals = new PredictTrueVal(id) // they share the same id
|
||||
newPredictTrueVals.slot = predictSlot.id
|
||||
newPredictTrueVals.trueValue = event.params.trueValue
|
||||
newPredictTrueVals.block = event.block.number.toI32()
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { NFTCreated, TokenCreated } from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { ERC721Template } from '../@types/templates/ERC721Template/ERC721Template'
|
||||
import { ERC20Template } from '../@types/templates/ERC20Template/ERC20Template'
|
||||
import { ERC20Template3 } from '../@types/templates/ERC20Template3/ERC20Template3'
|
||||
import { decimal } from './utils/constants'
|
||||
import { weiToDecimal } from './utils/generic'
|
||||
|
||||
import {
|
||||
ERC20Template as factoryERC20Template,
|
||||
ERC20Template3 as factoryERC20Template3
|
||||
} from '../@types/templates'
|
||||
import { getUser } from './utils/userUtils'
|
||||
import { getToken, getNftToken, getPredictContract } from './utils/tokenUtils'
|
||||
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)
|
||||
|
@ -60,6 +63,7 @@ export function handleNewToken(event: TokenCreated): void {
|
|||
token.save()
|
||||
addDatatoken()
|
||||
if (token.templateId == 3) {
|
||||
factoryERC20Template3.create(event.params.newTokenAddress)
|
||||
const predictContract = getPredictContract(event.params.newTokenAddress)
|
||||
predictContract.timestamp = event.block.timestamp.toI32()
|
||||
predictContract.txId = event.transaction.hash.toHex()
|
||||
|
@ -67,4 +71,5 @@ export function handleNewToken(event: TokenCreated): void {
|
|||
predictContract.eventIndex = event.logIndex.toI32()
|
||||
predictContract.save()
|
||||
}
|
||||
factoryERC20Template.create(event.params.newTokenAddress)
|
||||
}
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
import { Address, log, BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
import { Nft, Token, PredictContract } from '../../@types/schema'
|
||||
import { ERC20 } from '../../@types/templates/ERC20Template/ERC20'
|
||||
import {
|
||||
ERC20Template,
|
||||
ERC721Template,
|
||||
ERC20Template3
|
||||
} from '../../@types/templates'
|
||||
import { ERC721Template } from '../../@types/templates'
|
||||
import { addNft } from './globalUtils'
|
||||
import { ZERO_ADDRESS } from './constants'
|
||||
|
||||
export function createToken(address: Address, isDatatoken: boolean): Token {
|
||||
log.debug('started creating token with address: {}', [address.toHexString()])
|
||||
if (isDatatoken) {
|
||||
ERC20Template.create(address)
|
||||
}
|
||||
const token = new Token(address.toHexString())
|
||||
const contract = ERC20.bind(address)
|
||||
const name = contract.try_name()
|
||||
|
@ -117,7 +110,6 @@ export function getUSDValue(
|
|||
}
|
||||
|
||||
export function createPredictContract(address: Address): PredictContract {
|
||||
ERC20Template3.create(address)
|
||||
const predictContract = new PredictContract(address.toHexString())
|
||||
const token = getToken(address, true)
|
||||
predictContract.token = token.id
|
||||
|
|
Loading…
Reference in New Issue