Skip to content
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

Sync staging changes #263

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"prepare:test-l2": "yarn && yarn prep:addresses:test:l2 && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/"
},
"devDependencies": {
"@graphprotocol/contracts": "5.3.3",
"@graphprotocol/graph-cli": "^0.49.0",
"@graphprotocol/graph-ts": "^0.29.1",
"@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",
Expand Down
26 changes: 15 additions & 11 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ type GraphNetwork @entity {
subgraphDeploymentCount: Int!
"Total epochs"
epochCount: Int!
"Total amount of allocations opened"
allocationCount: Int!
"Total amount of allocations currently active"
activeAllocationCount: Int!

# Dispute Manager global variables
"Dispute arbitrator"
Expand Down Expand Up @@ -243,8 +247,8 @@ type GraphAccount @entity {
"Default display name is the current default name. Used for filtered queries in the explorer"
defaultDisplayName: String

# IPFS Metadata.
metadata: GraphAccountMetadata
# IPFS Meta.
metadata: GraphAccountMeta

# Operator info
"Operator of other Graph Accounts"
Expand Down Expand Up @@ -297,7 +301,7 @@ type GraphAccount @entity {
tokenLockWallets: [TokenLockWallet!]!
}

type GraphAccountMetadata @entity(immutable:true) {
type GraphAccountMeta @entity(immutable:true) {
"IPFS hash with account metadata details"
id: ID!
"Account that reference this metadata file. For compatibility purposes. For the full list use graphAccounts"
Expand Down Expand Up @@ -429,17 +433,17 @@ type Subgraph @entity {
"Total amount of NameSignal entities"
nameSignalCount: Int!

# Metadata from IPFS linked in GNS
# Meta from IPFS linked in GNS
"Subgraph metadata"
metadataHash: Bytes
"Subgraph metadata ipfs hash and entity"
metadata: SubgraphMetadata
metadata: SubgraphMeta

# Auxiliary fields
currentVersionRelationEntity: CurrentSubgraphDeploymentRelation
}

type SubgraphMetadata @entity(immutable:true) {
type SubgraphMeta @entity(immutable:true) {
"Subgraph metadata ipfs hash"
id: ID!
"Subgraph that reference this metadata. For compatibility purposes. For the full list use subgraphs"
Expand Down Expand Up @@ -496,15 +500,15 @@ type SubgraphVersion @entity {
createdAt: Int!

metadataHash: Bytes
# Metadata from IPFS linked in GNS
metadata: SubgraphVersionMetadata
# Meta from IPFS linked in GNS
metadata: SubgraphVersionMeta

entityVersion: Int!
"[DEPRECATED] Used for duplicate entities to enable old IDs from before the subgraph NFT update"
linkedEntity: SubgraphVersion
}

type SubgraphVersionMetadata @entity(immutable:true) {
type SubgraphVersionMeta @entity(immutable:true) {
"Subgraph version metadata ipfs hash"
id: ID!
"SubgraphVersion entity that references this metadata. For compatibility purposes. For the full list use subgraphVersions"
Expand Down Expand Up @@ -650,7 +654,7 @@ type SubgraphDeploymentManifest @entity(immutable:true) {
# }

"""
Metadata for the Indexer along with parameters and staking data
Meta for the Indexer along with parameters and staking data
"""
type Indexer @entity {
"Eth address of Indexer"
Expand Down Expand Up @@ -1448,7 +1452,7 @@ type _Schema_
name: "subgraphMetadataSearch"
language: en
algorithm: rank
include: [{ entity: "SubgraphMetadata", fields: [{ name: "displayName" }, { name: "description" }] }]
include: [{ entity: "SubgraphMeta", fields: [{ name: "displayName" }, { name: "description" }] }]
)
@fulltext(
name: "curatorSearch"
Expand Down
2 changes: 2 additions & 0 deletions src/mappings/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ export function createOrLoadGraphNetwork(
graphNetwork.subgraphCount = 0
graphNetwork.subgraphDeploymentCount = 0
graphNetwork.activeSubgraphCount = 0
graphNetwork.allocationCount = 0
graphNetwork.activeAllocationCount = 0

graphNetwork.arbitrator = Address.fromString('0x0000000000000000000000000000000000000000')
graphNetwork.querySlashingPercentage = 0
Expand Down
12 changes: 6 additions & 6 deletions src/mappings/ipfs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { json, Bytes, dataSource, JSONValueKind, log, DataSourceContext } from '@graphprotocol/graph-ts'
import {
SubgraphMetadata,
SubgraphVersionMetadata,
GraphAccountMetadata,
SubgraphMeta,
SubgraphVersionMeta,
GraphAccountMeta,
SubgraphDeploymentSchema,
SubgraphDeploymentManifest,
} from '../types/schema'
Expand All @@ -13,7 +13,7 @@ import { jsonToString } from './utils'

export function handleSubgraphMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let subgraphMetadata = new SubgraphMetadata(id)
let subgraphMetadata = new SubgraphMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand Down Expand Up @@ -41,7 +41,7 @@ export function handleSubgraphMetadata(content: Bytes): void {

export function handleSubgraphVersionMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let subgraphVersionMetadata = new SubgraphVersionMetadata(id)
let subgraphVersionMetadata = new SubgraphVersionMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand All @@ -53,7 +53,7 @@ export function handleSubgraphVersionMetadata(content: Bytes): void {

export function handleGraphAccountMetadata(content: Bytes): void {
let id = dataSource.context().getString("id")
let graphAccountMetadata = new GraphAccountMetadata(id)
let graphAccountMetadata = new GraphAccountMeta(id)
let tryData = json.try_fromBytes(content)
if (tryData.isOk) {
let data = tryData.value.toObject()
Expand Down
4 changes: 4 additions & 0 deletions src/mappings/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ export function handleAllocationCreated(event: AllocationCreated): void {

// update graph network
graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.plus(event.params.tokens)
graphNetwork.allocationCount = graphNetwork.allocationCount + 1
graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount + 1
graphNetwork.save()

// update subgraph deployment
Expand Down Expand Up @@ -519,6 +521,7 @@ export function handleAllocationClosed(event: AllocationClosed): void {
deployment.save()

// update graph network
graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount - 1
graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.minus(event.params.tokens)
graphNetwork.save()
}
Expand Down Expand Up @@ -598,6 +601,7 @@ export function handleAllocationClosedCobbDouglas(event: AllocationClosed1): voi
deployment.save()

// update graph network
graphNetwork.activeAllocationCount = graphNetwork.activeAllocationCount - 1
graphNetwork.totalTokensAllocated = graphNetwork.totalTokensAllocated.minus(event.params.tokens)
graphNetwork.save()
}
Expand Down
15 changes: 11 additions & 4 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
specVersion: 0.0.5
specVersion: 1.0.0
description: Core Graph Network subgraph (FDS version)
repository: https://github.com/graphprotocol/graph-network-subgraph
schema:
file: ./schema.graphql
features:
- fullTextSearch
indexerHints:
{{#isL1}}
prune: 400
{{/isL1}}
{{^isL1}}
prune: 15000
{{/isL1}}
dataSources:
- kind: ethereum/contract
name: Controller
Expand Down Expand Up @@ -726,7 +733,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleSubgraphMetadata
entities:
- SubgraphMetadata
- SubgraphMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json
Expand All @@ -738,7 +745,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleSubgraphVersionMetadata
entities:
- SubgraphVersionMetadata
- SubgraphVersionMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json
Expand All @@ -750,7 +757,7 @@ templates:
file: ./src/mappings/ipfs.ts
handler: handleGraphAccountMetadata
entities:
- GraphAccountMetadata
- GraphAccountMeta
abis:
- name: EpochManager
file: ./node_modules/@graphprotocol/contracts/dist/abis/EpochManager.json
Loading
Loading