diff --git a/packages/subgraph/schema.graphql b/packages/subgraph/schema.graphql index 6dfb7ce8..72559c5a 100644 --- a/packages/subgraph/schema.graphql +++ b/packages/subgraph/schema.graphql @@ -14,6 +14,7 @@ type DonorCollective @entity { collective: Collective! contribution: BigInt! # This is the total contribution of the donor to the collective flowRate: BigInt! + timestamp: BigInt! } type Steward @entity { @@ -98,7 +99,7 @@ type ProvableNFT @entity { owner: String! hash: String! steward: [Steward!]! @derivedFrom(field: "nfts") - collective: Collective! + collective: Collective # This is always populated, but not by the same handler that creates the ProvableNFT } type EventData @entity { diff --git a/packages/subgraph/src/mappings/pool.ts b/packages/subgraph/src/mappings/pool.ts index c9f1ed7f..359a62da 100644 --- a/packages/subgraph/src/mappings/pool.ts +++ b/packages/subgraph/src/mappings/pool.ts @@ -122,6 +122,9 @@ export function handleRewardClaim(event: EventRewardClaimed): void { let steward = Steward.load(contributors[i].toHexString()); if (steward === null) { steward = new Steward(contributors[i].toHexString()); + steward.actions = 0; + steward.totalEarned = BigInt.fromI32(0); + steward.nfts = new Array(); } steward.nfts.push(nftId); steward.actions = steward.actions + 1; @@ -132,6 +135,8 @@ export function handleRewardClaim(event: EventRewardClaimed): void { let stewardCollective = StewardCollective.load(stewardCollectiveId); if (stewardCollective === null) { stewardCollective = new StewardCollective(stewardCollectiveId); + stewardCollective.actions = 0; + stewardCollective.totalEarned = BigInt.fromI32(0); } stewardCollective.actions = stewardCollective.actions + 1; stewardCollective.totalEarned = stewardCollective.totalEarned.plus(totalReward); diff --git a/packages/subgraph/src/mappings/poolFactory.ts b/packages/subgraph/src/mappings/poolFactory.ts index 42556374..b393a7b8 100644 --- a/packages/subgraph/src/mappings/poolFactory.ts +++ b/packages/subgraph/src/mappings/poolFactory.ts @@ -7,6 +7,7 @@ import { import { Collective, PoolSettings, SafetyLimits } from '../../generated/schema'; import { createOrUpdateIpfsCollective } from './ipfsCollective'; import { DirectPaymentsPool } from '../../generated/templates'; +import { BigInt } from '@graphprotocol/graph-ts'; export function handlePoolDetailsChanged(event: PoolDetailsChanged): void { const poolAddress = event.params.pool; @@ -60,6 +61,7 @@ export function handlePoolCreated(event: PoolCreated): void { directPaymentPool.paymentsMade = 0; directPaymentPool.totalDonations = new BigInt(0); directPaymentPool.totalRewards = new BigInt(0); + // Pool Settings directPaymentPoolSettings.nftType = nftType; directPaymentPoolSettings.manager = poolSettings.manager; diff --git a/packages/subgraph/src/mappings/superApp.ts b/packages/subgraph/src/mappings/superApp.ts index 2e68adab..f7d74176 100644 --- a/packages/subgraph/src/mappings/superApp.ts +++ b/packages/subgraph/src/mappings/superApp.ts @@ -24,6 +24,7 @@ export function handleSupport(event: SupporterUpdated): void { if (donor == null) { donor = new Donor(donorAddress); donor.joined = timestamp; + donor.totalDonated = BigInt.fromI32(0); } donor.totalDonated = donor.totalDonated.plus(contributionDelta); @@ -37,6 +38,7 @@ export function handleSupport(event: SupporterUpdated): void { // This value is updated in _updateSupporter at line 260 of GoodCollectiveSuperApp.sol before the event is emitted donorCollective.contribution = event.params.contribution; donorCollective.flowRate = event.params.flowRate; + donorCollective.timestamp = timestamp; donorCollective.donor = donor.id; donorCollective.collective = pool.id; diff --git a/packages/subgraph/tsconfig.json b/packages/subgraph/tsconfig.json index 0009c63f..b68eb5f6 100644 --- a/packages/subgraph/tsconfig.json +++ b/packages/subgraph/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "assemblyscript/std/assembly.json", + "extends": "./node_modules/assemblyscript/std/assembly.json", "include": [ "./src/**/*.ts", ], diff --git a/yarn.lock b/yarn.lock index f6a5e3de..c40dd9cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -39301,7 +39301,7 @@ __metadata: "typescript@patch:typescript@5#~builtin, typescript@patch:typescript@^5.1.3#~builtin": version: 5.2.2 - resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin::version=5.2.2&hash=14eedb" + resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin::version=5.2.2&hash=5da071" bin: tsc: bin/tsc tsserver: bin/tsserver