Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/web3Integrations' into kris/real…
Browse files Browse the repository at this point in the history
…time-donation-flow
krisbitney committed Dec 26, 2023
2 parents 99ab3af + 3bdaa4a commit 48f2507
Showing 5 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
@@ -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 {
5 changes: 5 additions & 0 deletions packages/subgraph/src/mappings/pool.ts
Original file line number Diff line number Diff line change
@@ -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<string>();
}
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);
2 changes: 2 additions & 0 deletions packages/subgraph/src/mappings/poolFactory.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 2 additions & 0 deletions packages/subgraph/src/mappings/superApp.ts
Original file line number Diff line number Diff line change
@@ -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;

2 changes: 1 addition & 1 deletion packages/subgraph/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "assemblyscript/std/assembly.json",
"extends": "./node_modules/assemblyscript/std/assembly.json",
"include": [
"./src/**/*.ts",
],

0 comments on commit 48f2507

Please sign in to comment.