Repository navigation
Batch update deployment signalled tokens to Subgraph entity #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0025940
809ea84
8d8ef86
92cf1fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ import { | |
| createOrLoadSubgraph, | ||
| joinID, | ||
| createOrLoadNameSignal, | ||
| updateCurrentDeploymentLinks, | ||
| } from './helpers' | ||
| import { fetchSubgraphMetadata, fetchSubgraphVersionMetadata } from './metadataHelpers' | ||
|
|
||
|
|
@@ -199,6 +200,7 @@ export function handleSubgraphPublished(event: SubgraphPublished): void { | |
|
|
||
| // Update subgraph | ||
| let subgraph = createOrLoadSubgraph(subgraphID, event.params.graphAccount, event.block.timestamp) | ||
| let oldVersionID = subgraph.currentVersion | ||
|
|
||
| versionID = joinID([subgraphID, subgraph.versionCount.toString()]) | ||
| subgraph.currentVersion = versionID | ||
|
|
@@ -211,7 +213,7 @@ export function handleSubgraphPublished(event: SubgraphPublished): void { | |
|
|
||
| // Create subgraph deployment, if needed. Can happen if the deployment has never been staked on | ||
| let subgraphDeploymentID = event.params.subgraphDeploymentID.toHexString() | ||
| createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp) | ||
| let deployment = createOrLoadSubgraphDeployment(subgraphDeploymentID, event.block.timestamp) | ||
|
|
||
| // Create subgraph version | ||
| let subgraphVersion = new SubgraphVersion(versionID) | ||
|
|
@@ -224,6 +226,18 @@ export function handleSubgraphPublished(event: SubgraphPublished): void { | |
| subgraphVersion.metadataHash = event.params.versionMetadata | ||
| subgraphVersion = fetchSubgraphVersionMetadata(subgraphVersion, base58Hash) | ||
| subgraphVersion.save() | ||
|
|
||
| let oldDeployment: SubgraphDeployment | null = null | ||
| if (oldVersionID != null) { | ||
| let oldVersion = SubgraphVersion.load(oldVersionID) | ||
| oldDeployment = SubgraphDeployment.load(oldVersion.subgraphDeployment) | ||
| } | ||
| // create deployment - named subgraph relationship, and update the old one | ||
| updateCurrentDeploymentLinks( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this function, or one similar to it, will have to run on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be best to track that as a separate count, like having |
||
| oldDeployment, | ||
| deployment, | ||
| subgraph as Subgraph, | ||
| ) | ||
| } | ||
| /** | ||
| * @dev handleSubgraphDeprecated | ||
|
|
@@ -243,6 +257,19 @@ export function handleSubgraphDeprecated(event: SubgraphDeprecated): void { | |
| let graphNetwork = GraphNetwork.load('1') | ||
| graphNetwork.activeSubgraphCount = graphNetwork.activeSubgraphCount - 1 | ||
| graphNetwork.save() | ||
|
|
||
|
|
||
| let version = SubgraphVersion.load(subgraph.currentVersion) | ||
| if (version != null) { | ||
| let deployment = SubgraphDeployment.load(version.subgraphDeployment) | ||
|
|
||
| updateCurrentDeploymentLinks( | ||
| deployment, | ||
| null, | ||
| subgraph as Subgraph, | ||
| true | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export function handleNameSignalEnabled(event: NameSignalEnabled): void { | ||
|
|
@@ -266,9 +293,6 @@ export function handleNSignalMinted(event: NSignalMinted): void { | |
| subgraph.nameSignalAmount = subgraph.nameSignalAmount.plus(event.params.nSignalCreated) | ||
| subgraph.signalAmount = subgraph.signalAmount.plus(event.params.vSignalCreated) | ||
| subgraph.signalledTokens = subgraph.signalledTokens.plus(event.params.tokensDeposited) | ||
| subgraph.currentSignalledTokens = subgraph.currentSignalledTokens.plus( | ||
| event.params.tokensDeposited, | ||
| ) | ||
| subgraph.save() | ||
|
|
||
| // Update the curator | ||
|
|
@@ -347,7 +371,7 @@ export function handleNSignalMinted(event: NSignalMinted): void { | |
| curator.activeNameSignalCount = curator.activeNameSignalCount + 1 | ||
| curator.activeCombinedSignalCount = curator.activeCombinedSignalCount + 1 | ||
|
|
||
| if(curator.activeCombinedSignalCount == 1) { | ||
| if (curator.activeCombinedSignalCount == 1) { | ||
| let graphNetwork = GraphNetwork.load('1') | ||
| graphNetwork.activeCuratorCount = graphNetwork.activeCuratorCount + 1 | ||
| graphNetwork.save() | ||
|
|
@@ -379,9 +403,6 @@ export function handleNSignalBurned(event: NSignalBurned): void { | |
| subgraph.nameSignalAmount = subgraph.nameSignalAmount.minus(event.params.nSignalBurnt) | ||
| subgraph.signalAmount = subgraph.signalAmount.minus(event.params.vSignalBurnt) | ||
| subgraph.unsignalledTokens = subgraph.unsignalledTokens.plus(event.params.tokensReceived) | ||
| subgraph.currentSignalledTokens = subgraph.currentSignalledTokens.minus( | ||
| event.params.tokensReceived, | ||
| ) | ||
| subgraph.save() | ||
|
|
||
| // update name signal | ||
|
|
@@ -458,7 +479,7 @@ export function handleNSignalBurned(event: NSignalBurned): void { | |
| curator.activeNameSignalCount = curator.activeNameSignalCount - 1 | ||
| curator.activeCombinedSignalCount = curator.activeCombinedSignalCount - 1 | ||
|
|
||
| if(curator.activeCombinedSignalCount == 0) { | ||
| if (curator.activeCombinedSignalCount == 0) { | ||
| let graphNetwork = GraphNetwork.load('1') | ||
| graphNetwork.activeCuratorCount = graphNetwork.activeCuratorCount - 1 | ||
| graphNetwork.save() | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't
let oldVersionID = subgraph.currentVersionline of code be after this line? (After we setsubgraph.currentVersion) ?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually want to maintain the previous version id (before we set the new one, even if it's null) that's why I do it before.
This is done to be able to properly update the old version helper entity and also the active amount of subgraphs that currently are linked to this deployment.