diff --git a/package.json b/package.json index b493ee3..262abf3 100644 --- a/package.json +++ b/package.json @@ -13,22 +13,17 @@ "prepublishOnly": "yarn & yarn build:ipfs", "build": "graph build", "build:ipfs:mainnet": "yarn && yarn prepare:mainnet && graph build --ipfs https://ipfs.network.thegraph.com", - "deploy-mainnet-staging": "yarn && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet-staging --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "deploy-mainnet": "yarn && yarn prepare:mainnet && graph deploy graphprotocol/graph-network-mainnet --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "deploy-arbitrum": "yarn && yarn prepare:arbitrum && graph deploy graphprotocol/graph-network-arbitrum --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "deploy-goerli": "yarn && yarn prepare:goerli && graph deploy graphprotocol/graph-network-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "deploy-arbitrum-goerli": "yarn && yarn prepare:arbitrum-goerli && graph deploy graphprotocol/graph-network-arbitrum-goerli --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "deploy-testing": "yarn && yarn prepare: && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", - "prep:addresses:goerli": "ts-node config/goerliAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", - "prepare:goerli": "yarn prep:addresses:goerli && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", + "deploy-mainnet": "yarn && yarn prepare:mainnet && graph deploy --studio graph-network-ethereum", + "deploy-arbitrum": "yarn && yarn prepare:arbitrum && graph deploy --studio graph-network-arbitrum", + "deploy-sepolia": "yarn && yarn prepare:sepolia && graph deploy --studio graph-network-sepolia", + "deploy-arbitrum-sepolia": "yarn && yarn prepare:arbitrum-sepolia && graph deploy --studio graph-network-arbitrum-sepolia", + "deploy-studio": "yarn deploy-mainnet && yarn deploy-arbitrum && yarn deploy-sepolia && yarn deploy-arbitrum-sepolia", "prep:addresses:sepolia": "ts-node config/sepoliaAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", "prepare:sepolia": "yarn prep:addresses:sepolia && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", "prep:addresses:mainnet": "ts-node config/mainnetAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", "prepare:mainnet": "yarn prep:addresses:mainnet && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", "prep:addresses:arbitrum": "ts-node config/mainnetArbitrumAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", "prepare:arbitrum": "yarn prep:addresses:arbitrum && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", - "prep:addresses:arbitrum-goerli": "ts-node config/arbitrumGoerliAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", - "prepare:arbitrum-goerli": "yarn prep:addresses:arbitrum-goerli && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", "prep:addresses:arbitrum-sepolia": "ts-node config/arbitrumSepoliaAddressScript.ts && mustache ./config/generatedAddresses.json ./config/addresses.template.ts > ./config/addresses.ts", "prepare:arbitrum-sepolia": "yarn prep:addresses:arbitrum-sepolia && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/", "prep:ipfs": "mustache ./config/ipfs.json ./src/mappings/helpers/metadata.template.ts > ./src/mappings/helpers/metadata.ts", diff --git a/src/mappings/curation.ts b/src/mappings/curation.ts index 24b962b..b050725 100644 --- a/src/mappings/curation.ts +++ b/src/mappings/curation.ts @@ -170,9 +170,16 @@ export function handleBurned(event: Burned): void { let gnsID = graphNetwork.gns.toHexString() // Update signal let subgraphDeploymentID = event.params.subgraphDeploymentID.toHexString() - let signalID = joinID([id, subgraphDeploymentID]) - let signal = Signal.load(signalID)! + // Assuming signal is created since it's a burn can't be done, as signals can be transferred and + // we currently can't track transfers. On those edge cases values will be weird here, but + // overall network wide should still make sense + let signal = createOrLoadSignal( + id, + subgraphDeploymentID, + (addresses.isL1 ? event.block.number : graphNetwork.currentL1BlockNumber!).toI32(), + event.block.timestamp.toI32(), + ) let gnsSignalOldAmount = signal.signal.toBigDecimal() let isSignalBecomingInactive = !signal.signal.isZero() && event.params.signal == signal.signal @@ -205,8 +212,10 @@ export function handleBurned(event: Burned): void { gnsSignalNewAmount = gnsSignal != null ? gnsSignal.signal.toBigDecimal() : zeroBD } - // Update curator - let curator = Curator.load(id)! + // Assuming curator is created since it's a burn can't be done, as signals can be transferred and + // we currently can't track transfers, thus this might be the first curation interaction of this + // account + let curator = createOrLoadCurator(event.params.curator, event.block.timestamp) curator.totalUnsignalledTokens = curator.totalUnsignalledTokens.plus(event.params.tokens) curator.totalSignal = curator.totalSignal.minus(event.params.signal.toBigDecimal()) curator.totalSignalAverageCostBasis = curator.totalSignalAverageCostBasis.minus(diffACB) @@ -229,7 +238,7 @@ export function handleBurned(event: Burned): void { curator.save() - // Update subgraph + // Deployment can be safely assumed as existing, since someone had to have signaled in order to burn let deployment = SubgraphDeployment.load(subgraphDeploymentID)! let oldSignalAmount = deployment.signalAmount let oldSignalledTokens = deployment.signalledTokens diff --git a/src/mappings/gns.ts b/src/mappings/gns.ts index b1a1c9c..d79607a 100644 --- a/src/mappings/gns.ts +++ b/src/mappings/gns.ts @@ -274,11 +274,13 @@ export function handleSubgraphDeprecated(event: SubgraphDeprecated): void { graphNetwork.activeSubgraphCount = graphNetwork.activeSubgraphCount - 1 graphNetwork.save() - let version = SubgraphVersion.load(subgraph.currentVersion!) - if (version != null) { - let deployment = SubgraphDeployment.load(version.subgraphDeployment) + if (subgraph.currentVersion != null) { + let version = SubgraphVersion.load(subgraph.currentVersion!) + if (version != null) { + let deployment = SubgraphDeployment.load(version.subgraphDeployment) - updateCurrentDeploymentLinks(deployment, null, subgraph as Subgraph, true) + updateCurrentDeploymentLinks(deployment, null, subgraph as Subgraph, true) + } } } @@ -612,7 +614,7 @@ export function handleGRTWithdrawn(event: GRTWithdrawn): void { nameSignal.signalAverageCostBasisPerSignal = BigDecimal.fromString('0') nameSignal.save() - let curator = Curator.load(event.params.nameCurator.toHexString())! + let curator = createOrLoadCurator(event.params.nameCurator, event.block.timestamp) curator.totalWithdrawnTokens = curator.totalWithdrawnTokens.plus(event.params.withdrawnGRT) curator.save() } @@ -701,11 +703,13 @@ export function handleSubgraphDeprecatedV2(event: SubgraphDeprecated1): void { graphNetwork.activeSubgraphCount = graphNetwork.activeSubgraphCount - 1 graphNetwork.save() - let version = SubgraphVersion.load(subgraph.currentVersion!) - if (version != null) { - let deployment = SubgraphDeployment.load(version.subgraphDeployment) + if (subgraph.currentVersion != null) { + let version = SubgraphVersion.load(subgraph.currentVersion!) + if (version != null) { + let deployment = SubgraphDeployment.load(version.subgraphDeployment) - updateCurrentDeploymentLinks(deployment, null, subgraph as Subgraph, true) + updateCurrentDeploymentLinks(deployment, null, subgraph as Subgraph, true) + } } } @@ -990,7 +994,7 @@ export function handleGRTWithdrawnV2(event: GRTWithdrawn1): void { nameSignal.save() - let curator = Curator.load(event.params.curator.toHexString())! + let curator = createOrLoadCurator(event.params.curator, event.block.timestamp) curator.totalWithdrawnTokens = curator.totalWithdrawnTokens.plus(event.params.withdrawnGRT) curator.save() } @@ -1131,7 +1135,7 @@ export function handleSubgraphVersionUpdated(event: SubgraphVersionUpdated): voi // create deployment - named subgraph relationship, and update the old one updateCurrentDeploymentLinks(oldDeployment, deployment, subgraph as Subgraph) subgraphVersion.save() - + let context = new DataSourceContext() context.setString('id', metadataId) SubgraphVersionMetadataTemplate.createWithContext(base58Hash, context)