Skip to content

Commit

Permalink
yarn lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Jack committed Sep 18, 2023
1 parent 73e1861 commit cc81b88
Show file tree
Hide file tree
Showing 7 changed files with 1,181 additions and 10,799 deletions.
4 changes: 2 additions & 2 deletions packages/subgraph/config/celo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"network": "celo",
"DirectPaymentsFactoryAddress": "0xab51c7641Ae2bdf7cA2269cC64ddc3B4B560296f",
"ProvableNFTAddress": "0x3B2A0566895B0c0640dB30602A44A847BE7b0873"
"DirectPaymentsFactoryAddress": "0x58b5E37c5aFad520dD93E92A5D11B8721A9115F0",
"ProvableNFTAddress": "0x2AF5DB8249229ba696E0bac1a382aDb1fee040A6"
}
35 changes: 15 additions & 20 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,26 @@ type Donor @entity {
type DirectPaymentPool @entity {
"This is the address source"
id: String!
ipfs: String!
nftType: BigInt!
validEvents: [Int!]!
rewardPerEvent: [Int!]!
manager: Bytes!
membersValidator: Bytes!
ipfs: String
nftType: BigInt
manager: Bytes
contributions: BigInt
membersValidator: Bytes
uniquenessValidator: String
collective: Donor
steward: Steward
rewardToken: String!
projectId: String!
isVerified: Boolean!
limits: SafetyLimits!
nft: ProvableNFT!
claimedNfts: [String!]!
members: [String!]!
poolAddress: String!
timestamp: Int!
rewardToken: String
projectId: String
isVerified: Boolean
limits: SafetyLimits
nft: ProvableNFT
poolAddress: String
timestamp: Int
}

type PoolSettings @entity {
id: String!
nftType: BigInt!
validEvents: [Int!]!
rewardPerEvent: [Int!]!
manager: Bytes!
membersValidator: Bytes!
uniquenessValidator: Bytes!
Expand All @@ -54,9 +49,9 @@ type PoolSettings @entity {

type SafetyLimits @entity {
id: String!
maxTotalPerMonth: BigInt!
maxMemberPerMonth: BigInt!
maxMemberPerDay: BigInt!
maxTotalPerMonth: BigInt
maxMemberPerMonth: BigInt
maxMemberPerDay: BigInt
}

type ProvableNFT @entity {
Expand Down
5 changes: 1 addition & 4 deletions packages/subgraph/src/mappings/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function handlePoolCreated(event: PoolCreated): void {
directPaymentPool.poolAddress = poolAddress.toHexString();
directPaymentPool.isVerified = false;
directPaymentPool.projectId = projectID.toHexString();
directPaymentPool.manager = event.address;
directPaymentPool.timestamp = event.block.timestamp.toI32();
directPaymentPool.save();

Expand Down Expand Up @@ -92,10 +93,6 @@ export function handlePoolSettingsChange(event: PoolSettingsChanged): void {
directPaymentPoolSettings.nftType = poolSettings.nftType;
directPaymentPoolSettings.save();
}
if (poolSettings.validEvents != null) {
directPaymentPoolSettings.validEvents = poolSettings.validEvents;
directPaymentPoolSettings.save();
}
if (!poolSettings.manager) {
directPaymentPoolSettings.manager = poolSettings.manager;
directPaymentPoolSettings.save();
Expand Down
21 changes: 18 additions & 3 deletions packages/subgraph/src/mappings/superApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { log } from '@graphprotocol/graph-ts';
import { SupporterUpdated } from '../../generated/DirectPaymentsPool/DirectPaymentsPool';
import { Donor } from '../../generated/schema';
import { DirectPaymentPool, Donor } from '../../generated/schema';

export function handleSupport(event: SupporterUpdated): void {
let donar = event.params.supporter;
Expand All @@ -9,13 +10,27 @@ export function handleSupport(event: SupporterUpdated): void {
let rate = event.params.flowRate;
let update = event.params.isFlowUpdate;

let supporter = new Donor(donar.toHexString() + event.params.pool.toHexString());
let supporter = Donor.load(donar.toHexString() + event.params.pool.toHexString());
let pool = DirectPaymentPool.load(event.params.pool.toHexString());
if (supporter === null) {
supporter = new Donor(donar.toHexString() + event.params.pool.toHexString());
pool = new DirectPaymentPool(event.params.pool.toHexString());
pool.contributions = contributions;
supporter.id = donar.toHexString() + event.params.pool.toHexString();
supporter.joined = event.block.timestamp.toI32();
supporter.totalDonated = contributions;
pool.save();
supporter.save();
} else {
supporter.totalDonated = previousContribution.plus(contributions);
supporter.save();
}
supporter.save();

if (pool === null) {
log.error('Missing Payment Pool {}', [event.address.toHex()]);
return;
} else {
pool.contributions = previousContribution.plus(contributions);
pool.save();
}
}
29 changes: 26 additions & 3 deletions packages/subgraph/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dataSources:
source:
address: '{{DirectPaymentsFactoryAddress}}'
abi: DirectPaymentsFactory
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -34,7 +34,7 @@ dataSources:
network: {{network}}
source:
abi: DirectPaymentsPool
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -43,6 +43,7 @@ dataSources:
- DirectPaymentPool
- SafetyLimits
- PoolSettings

- Claim
abis:
- name: DirectPaymentsPool
Expand All @@ -65,7 +66,7 @@ dataSources:
source:
address: '{{ProvableNFTAddress}}'
abi: ProvableNFT
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -80,3 +81,25 @@ dataSources:
handler: handleNftMint

file: ./src/mappings/ProvableNFT.ts
- kind: ethereum
name: SuperApp
# prettier-ignore
network: {{network}}
source:
abi: GoodCollectiveSuperApp
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Donor
- DirectPaymentPool
abis:
- name: GoodCollectiveSuperApp
file: ./abis/DirectPaymentsPool.json
eventHandlers:
- event: SupporterUpdated(indexed address,uint256,uint256,int96,int96,bool,address)
handler: handleSupport

file: ./src/mappings/superApp.ts
33 changes: 28 additions & 5 deletions packages/subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ dataSources:
# prettier-ignore
network: celo
source:
address: '0xab51c7641Ae2bdf7cA2269cC64ddc3B4B560296f'
address: '0x58b5E37c5aFad520dD93E92A5D11B8721A9115F0'
abi: DirectPaymentsFactory
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -34,7 +34,7 @@ dataSources:
network: celo
source:
abi: DirectPaymentsPool
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -43,6 +43,7 @@ dataSources:
- DirectPaymentPool
- SafetyLimits
- PoolSettings

- Claim
abis:
- name: DirectPaymentsPool
Expand All @@ -63,9 +64,9 @@ dataSources:
# prettier-ignore
network: celo
source:
address: '0x3B2A0566895B0c0640dB30602A44A847BE7b0873'
address: '0x2AF5DB8249229ba696E0bac1a382aDb1fee040A6'
abi: ProvableNFT
startBlock: 19375523
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand All @@ -80,3 +81,25 @@ dataSources:
handler: handleNftMint

file: ./src/mappings/ProvableNFT.ts
- kind: ethereum
name: SuperApp
# prettier-ignore
network: celo
source:
abi: GoodCollectiveSuperApp
startBlock: 20920303
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Donor
- DirectPaymentPool
abis:
- name: GoodCollectiveSuperApp
file: ./abis/DirectPaymentsPool.json
eventHandlers:
- event: SupporterUpdated(indexed address,uint256,uint256,int96,int96,bool,address)
handler: handleSupport

file: ./src/mappings/superApp.ts
Loading

0 comments on commit cc81b88

Please sign in to comment.