Skip to content

Commit

Permalink
generate different subgraph yml file based on network selection
Browse files Browse the repository at this point in the history
  • Loading branch information
pettinarip committed Sep 16, 2021
1 parent e59a363 commit 27750cc
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"start:node": "yarn workspace @clrfund/contracts run node",
"start:web": "yarn workspace @clrfund/vue-app run serve",
"start:gun": "yarn workspace @clrfund/vue-app run gun",
"start:subgraph": "yarn workspace @clrfund/subgraph run prepare:hardhat && yarn build:subgraph && yarn deploy:local-subgraph",
"codegen": "graphql-codegen --config codegen.yml",
"test": "yarn workspace @clrfund/contracts run test && yarn workspace @clrfund/vue-app run test",
"test:contracts": "yarn workspace @clrfund/contracts run test",
Expand All @@ -37,6 +38,7 @@
"deploy:local": "yarn deploy:local-registry && yarn deploy:local-round",
"deploy:local-registry": "yarn workspace @clrfund/contracts run deploy:local",
"deploy:local-round": "yarn workspace @clrfund/contracts run deployTestRound:local",
"deploy:local-subgraph": "yarn workspace @clrfund/subgraph run create-local && yarn workspace @clrfund/subgraph run deploy-local",
"upgrade:local": "yarn workspace @clrfund/contracts run upgrade:local",
"lint": "yarn workspaces run lint",
"lint:contracts": "yarn workspace @clrfund/contracts run lint",
Expand Down
2 changes: 1 addition & 1 deletion subgraph/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/node_modules
/build
/packages/*/node_modules
.DS_Store
.DS_Store
5 changes: 5 additions & 0 deletions subgraph/config/hardhat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"network": "hardhat",
"address": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"startBlock": 0
}
5 changes: 5 additions & 0 deletions subgraph/config/xdai.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"network": "xdai",
"address": "0x549F91A93c94358C5f5380D7ABF23E1340CfF2db",
"startBlock": 15217676
}
5 changes: 4 additions & 1 deletion subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"author": "daodesigner",
"private": true,
"scripts": {
"prepare:hardhat": "mustache config/hardhat.json subgraph.template.yaml > subgraph.yaml",
"prepare:xdai": "mustache config/xdai.json subgraph.template.yaml > subgraph.yaml",
"codegen": "graph codegen",
"lint:js": "eslint 'src/*.ts'",
"lint": "yarn lint:js",
Expand All @@ -32,6 +34,7 @@
"@typescript-eslint/parser": "^2.34.0",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^8.3.0"
"eslint-config-prettier": "^8.3.0",
"mustache": "^4.2.0"
}
}
156 changes: 156 additions & 0 deletions subgraph/subgraph.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
specVersion: 0.0.2
description: clr.fund sandbox
repository: https://github.com/daodesigner/clrfund-deployer
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: FundingRoundFactory
network: {{network}}
source:
address: '{{address}}'
abi: FundingRoundFactory
startBlock: {{startBlock}}
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- FundingRoundFactory
- RecipientRegistry
- ContributorRegistry
- FundingRound
abis:
- name: FundingRoundFactory
file: ./abis/FundingRoundFactory.json
- name: FundingRound
file: ./abis/FundingRound.json
- name: MACIFactory
file: ./abis/MACIFactory.json
- name: OptimisticRecipientRegistry
file: ./abis/OptimisticRecipientRegistry.json
- name: BrightIdUserRegistry
file: ./abis/BrightIdUserRegistry.json
eventHandlers:
- event: CoordinatorChanged(address)
handler: handleCoordinatorChanged
- event: FundingSourceAdded(address)
handler: handleFundingSourceAdded
- event: FundingSourceRemoved(address)
handler: handleFundingSourceRemoved
- event: OwnershipTransferred(indexed address,indexed address)
handler: handleOwnershipTransferred
- event: RoundFinalized(address)
handler: handleRoundFinalized
- event: RoundStarted(address)
handler: handleRoundStarted
- event: TokenChanged(address)
handler: handleTokenChanged
file: ./src/FundingRoundFactoryMapping.ts
- kind: ethereum/contract
name: OptimisticRecipientRegistry
network: {{network}}
source:
abi: OptimisticRecipientRegistry
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- RecipientRegistry
- Recipient
abis:
- name: OptimisticRecipientRegistry
file: ./abis/OptimisticRecipientRegistry.json
eventHandlers:
- event: OwnershipTransferred(indexed address,indexed address)
handler: handleOwnershipTransferred
- event: RequestResolved(indexed bytes32,indexed uint8,indexed bool,uint256,uint256)
handler: handleRequestResolved
- event: RequestSubmitted(indexed bytes32,indexed uint8,address,string,uint256)
handler: handleRequestSubmitted
file: ./src/OptimisticRecipientRegistryMapping.ts
templates:
- name: FundingRound
kind: ethereum/contract
network: {{network}}
source:
abi: FundingRound
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- FundingRound
- Contribution
- Donation
- Recipient
- Contributor
abis:
- name: FundingRound
file: ./abis/FundingRound.json
- name: OptimisticRecipientRegistry
file: ./abis/OptimisticRecipientRegistry.json
- name: BrightIdUserRegistry
file: ./abis/BrightIdUserRegistry.json
eventHandlers:
- event: Contribution(indexed address,uint256)
handler: handleContribution
- event: ContributionWithdrawn(indexed address)
handler: handleContributionWithdrawn
- event: FundsClaimed(indexed uint256,indexed address,uint256)
handler: handleFundsClaimed
- event: OwnershipTransferred(indexed address,indexed address)
handler: handleOwnershipTransferred
- event: TallyPublished(string)
handler: handleTallyPublished
- event: Voted(indexed address)
handler: handleVoted
file: ./src/FundingRoundMapping.ts
- name: OptimisticRecipientRegistry
kind: ethereum/contract
network: {{network}}
source:
abi: OptimisticRecipientRegistry
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- RecipientRegistry
- Recipient
abis:
- name: OptimisticRecipientRegistry
file: ./abis/OptimisticRecipientRegistry.json
eventHandlers:
- event: OwnershipTransferred(indexed address,indexed address)
handler: handleOwnershipTransferred
- event: RequestResolved(indexed bytes32,indexed uint8,indexed bool,uint256,uint256)
handler: handleRequestResolved
- event: RequestSubmitted(indexed bytes32,indexed uint8,address,string,uint256)
handler: handleRequestSubmitted
file: ./src/OptimisticRecipientRegistryMapping.ts
- name: BrightIdUserRegistry
kind: ethereum/contract
network: {{network}}
source:
abi: BrightIdUserRegistry
mapping:
kind: ethereum/events
apiVersion: 0.0.4
language: wasm/assemblyscript
entities:
- ContributorRegistry
- Contributor
abis:
- name: BrightIdUserRegistry
file: ./abis/BrightIdUserRegistry.json
eventHandlers:
- event: OwnershipTransferred(indexed address,indexed address)
handler: handleOwnershipTransferred
- event: SetBrightIdSettings(bytes32,address)
handler: handleSetBrightIdSettings
- event: Sponsor(indexed address)
handler: handleSponsor
file: ./src/BrightIdUserRegistryMapping.ts
6 changes: 4 additions & 2 deletions subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dataSources:
name: FundingRoundFactory
network: xdai
source:
address: "0x549F91A93c94358C5f5380D7ABF23E1340CfF2db"
address: '0x549F91A93c94358C5f5380D7ABF23E1340CfF2db'
abi: FundingRoundFactory
startBlock: 15217676
mapping:
Expand Down Expand Up @@ -52,7 +52,7 @@ dataSources:
network: xdai
source:
abi: OptimisticRecipientRegistry
startBlock: 16105387
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.4
Expand Down Expand Up @@ -105,6 +105,8 @@ templates:
handler: handleOwnershipTransferred
- event: TallyPublished(string)
handler: handleTallyPublished
- event: Voted(indexed address)
handler: handleVoted
file: ./src/FundingRoundMapping.ts
- name: OptimisticRecipientRegistry
kind: ethereum/contract
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14578,6 +14578,11 @@ murmurhash3js@^3.0.1:
resolved "https://registry.yarnpkg.com/murmurhash3js/-/murmurhash3js-3.0.1.tgz#3e983e5b47c2a06f43a713174e7e435ca044b998"
integrity sha1-Ppg+W0fCoG9DpxMXTn5DXKBEuZg=

mustache@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.2.0.tgz#e5892324d60a12ec9c2a73359edca52972bf6f64"
integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==

[email protected]:
version "0.0.7"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
Expand Down

0 comments on commit 27750cc

Please sign in to comment.