diff --git a/package.json b/package.json index e198771..ec7d349 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ "prettier-write": "prettier --write '**/*.ts'" }, "devDependencies": { - "@graphprotocol/contracts": "5.3.3", - "@graphprotocol/graph-cli": "^0.51.0", - "@graphprotocol/graph-ts": "^0.31.0", + "@graphprotocol/contracts": "6.2.0", + "@graphprotocol/graph-cli": "0.68.0", + "@graphprotocol/graph-ts": "0.32.0", "@types/node": "^14.0.13", "@typescript-eslint/eslint-plugin": "^3.3.0", "@typescript-eslint/parser": "^3.3.0", diff --git a/src/mappings/ethereumDIDRegistry.ts b/src/mappings/ethereumDIDRegistry.ts index 7a10303..561acf2 100644 --- a/src/mappings/ethereumDIDRegistry.ts +++ b/src/mappings/ethereumDIDRegistry.ts @@ -17,7 +17,8 @@ export function handleDIDAttributeChanged(event: DIDAttributeChanged): void { // called it directly, it could crash the subgraph let hexHash = changetype(addQm(event.params.value)) let base58Hash = hexHash.toBase58() - let metadataId = graphAccount.id.concat('-').concat(base58Hash) + let uniqueTxID = event.transaction.hash.toHexString().concat('-').concat(event.logIndex.toString()) + let metadataId = uniqueTxID.concat('-').concat(graphAccount.id.concat('-').concat(base58Hash)) graphAccount.metadata = metadataId graphAccount.save() diff --git a/src/mappings/rewardsManager.ts b/src/mappings/rewardsManager.ts index d835038..beaebba 100644 --- a/src/mappings/rewardsManager.ts +++ b/src/mappings/rewardsManager.ts @@ -80,6 +80,7 @@ export function handleRewardsAssigned(event: RewardsAssigned): void { graphNetwork.totalIndexingDelegatorRewards = graphNetwork.totalIndexingDelegatorRewards.plus( delegatorIndexingRewards, ) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(delegatorIndexingRewards) graphNetwork.save() batchUpdateDelegatorsForIndexer(indexer.id, event.block.timestamp) diff --git a/src/mappings/staking.ts b/src/mappings/staking.ts index 03803d8..3ac9cbb 100644 --- a/src/mappings/staking.ts +++ b/src/mappings/staking.ts @@ -105,6 +105,7 @@ export function handleStakeLocked(event: StakeLocked): void { // update indexer let id = event.params.indexer.toHexString() let indexer = Indexer.load(id)! + let oldLockedTokens = indexer.lockedTokens indexer.lockedTokens = event.params.tokens indexer.tokensLockedUntil = event.params.until.toI32() indexer = updateAdvancedIndexerMetrics(indexer as Indexer) @@ -112,10 +113,12 @@ export function handleStakeLocked(event: StakeLocked): void { indexer.save() // update graph network + // the tokens from the event replace the previously locked tokens + // from this indexer let graphNetwork = createOrLoadGraphNetwork() graphNetwork.totalUnstakedTokensLocked = graphNetwork.totalUnstakedTokensLocked.plus( event.params.tokens, - ) + ).minus(oldLockedTokens) if (indexer.stakedTokens == indexer.lockedTokens) { graphNetwork.stakedIndexersCount = graphNetwork.stakedIndexersCount - 1 } @@ -710,6 +713,7 @@ export function handleRebateClaimed(event: RebateClaimed): void { graphNetwork.totalUnclaimedQueryFeeRebates = graphNetwork.totalUnclaimedQueryFeeRebates.minus( event.params.delegationFees.plus(event.params.tokens), ) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.delegationFees) graphNetwork.save() batchUpdateDelegatorsForIndexer(indexer.id, event.block.timestamp) @@ -817,6 +821,7 @@ export function handleRebateCollected(event: RebateCollected): void { graphNetwork.totalUnclaimedQueryFeeRebates = graphNetwork.totalUnclaimedQueryFeeRebates.minus( event.params.delegationRewards.plus(event.params.queryRebates), ) + graphNetwork.totalDelegatedTokens = graphNetwork.totalDelegatedTokens.plus(event.params.delegationRewards) graphNetwork.save() batchUpdateDelegatorsForIndexer(indexer.id, event.block.timestamp) diff --git a/subgraph.template.yaml b/subgraph.template.yaml index 6d76d63..422d8bd 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -1,8 +1,15 @@ -specVersion: 0.0.2 +specVersion: 1.0.0 description: Graph Network analytics subgraph repository: https://github.com/graphprotocol/graph-network-analytics-subgraph features: - fullTextSearch +indexerHints: +{{#isL1}} + prune: 400 +{{/isL1}} +{{^isL1}} + prune: 15000 +{{/isL1}} schema: file: ./schema.graphql dataSources: