Skip to content

Commit

Permalink
mappings/gns: Fix subgraphVersion.version value (was always set to 0)
Browse files Browse the repository at this point in the history
  • Loading branch information
fordN authored and juanmardefago committed Dec 2, 2021
1 parent 39f5c02 commit d845def
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/mappings/gns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigInt, BigDecimal, Bytes, json } from '@graphprotocol/graph-ts'
import { BigInt, BigDecimal, Bytes } from '@graphprotocol/graph-ts'
import {
SubgraphPublished,
SubgraphDeprecated,
Expand Down Expand Up @@ -197,15 +197,16 @@ export function handleSubgraphPublished(event: SubgraphPublished): void {
let subgraphNumber = event.params.subgraphNumber.toString()
let subgraphID = joinID([graphAccountID, subgraphNumber])
let versionID: string
let versionNumber: number
let versionNumber: BigInt

// Update subgraph
let subgraph = createOrLoadSubgraph(subgraphID, event.params.graphAccount, event.block.timestamp)
let oldVersionID = subgraph.currentVersion

versionID = joinID([subgraphID, subgraph.versionCount.toString()])
versionNumber = subgraph.versionCount
versionID = joinID([subgraphID, versionNumber.toString()])
subgraph.currentVersion = versionID
subgraph.versionCount = subgraph.versionCount.plus(BigInt.fromI32(1))
subgraph.versionCount = versionNumber.plus(BigInt.fromI32(1))

// Creates Graph Account, if needed
createOrLoadGraphAccount(graphAccountID, event.params.graphAccount, event.block.timestamp)
Expand All @@ -220,7 +221,7 @@ export function handleSubgraphPublished(event: SubgraphPublished): void {
let subgraphVersion = new SubgraphVersion(versionID)
subgraphVersion.subgraph = subgraphID
subgraphVersion.subgraphDeployment = subgraphDeploymentID
subgraphVersion.version = versionNumber as i32
subgraphVersion.version = versionNumber.toI32()
subgraphVersion.createdAt = event.block.timestamp.toI32()
let hexHash = changetype<Bytes>(addQm(event.params.versionMetadata))
let base58Hash = hexHash.toBase58()
Expand Down Expand Up @@ -604,7 +605,7 @@ export function handleGRTWithdrawn(event: GRTWithdrawn): void {
}

/**
* @dev handleParamterUpdated
* @dev handleParameterUpdated
* - updates all parameters of GNS, depending on string passed. We then can
* call the contract directly to get the updated value
*/
Expand Down

0 comments on commit d845def

Please sign in to comment.