parent
d7f8613680
commit
c0ff036b68
|
@ -0,0 +1,12 @@
|
|||
mainnet:
|
||||
contracts:
|
||||
LiquidPledging:
|
||||
address: "0x603A7249E64b8cACe20ffb55926145346ca42A97"
|
||||
startBlock: 7944388
|
||||
networkName: mainnet
|
||||
ropsten:
|
||||
contracts:
|
||||
LiquidPledging:
|
||||
address: "0x2cEfae94eB05737827D245E9cb6c1ca3C2A0Fe52"
|
||||
startBlock: 6157524
|
||||
networkName: ropsten
|
|
@ -4,10 +4,15 @@
|
|||
"scripts": {
|
||||
"codegen": "graph codegen",
|
||||
"build": "graph build",
|
||||
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ bgits/liquid-funding-rinkeby",
|
||||
"clean": "shx rm -rf ./build ./src/types ./subgraph.yaml",
|
||||
"deploy": "graph deploy $SUBGRAPH --debug --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
|
||||
"create-local": "graph create --node http://localhost:8020/ bgits/liquid-funding-rinkeby",
|
||||
"remove-local": "graph remove --node http://localhost:8020/ bgits/liquid-funding-rinkeby",
|
||||
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 bgits/liquid-funding-rinkeby"
|
||||
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 bgits/liquid-funding-rinkeby",
|
||||
"deploy:ropsten": "yarn prepare:ropsten && SUBGRAPH=bgits/liquid-funding-rinkeby yarn deploy",
|
||||
"deploy:mainnet": "yarn prepare:mainnet && SUBGRAPH=bgits/assemble yarn deploy",
|
||||
"prepare:ropsten": "NETWORK_NAME=ropsten node ./templatify.js",
|
||||
"prepare:mainnet": "NETWORK_NAME=mainnet node ./templatify.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphprotocol/graph-cli": "0.16.0",
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
specVersion: 0.0.2
|
||||
description: Assemble - funding projects for the common good
|
||||
schema:
|
||||
file: ./schema.graphql
|
||||
dataSources:
|
||||
- kind: ethereum/contract
|
||||
name: Contract
|
||||
network: {{networkName}}
|
||||
source:
|
||||
address: {{contracts.LiquidPledging.address}}
|
||||
abi: Contract
|
||||
startBlock: {{contracts.LiquidPledging.startBlock}}
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.3
|
||||
language: wasm/assemblyscript
|
||||
entities:
|
||||
- Transfer
|
||||
- CancelProject
|
||||
- GiverAdded
|
||||
- GiverUpdated
|
||||
- DelegateAdded
|
||||
- DelegateUpdated
|
||||
- ProjectAdded
|
||||
- ProjectUpdated
|
||||
- Profile
|
||||
abis:
|
||||
- name: Contract
|
||||
file: ./abis/Contract.json
|
||||
eventHandlers:
|
||||
- event: Transfer(indexed uint256,indexed uint256,uint256)
|
||||
handler: handleTransfer
|
||||
- event: CancelProject(indexed uint256)
|
||||
handler: handleCancelProject
|
||||
- event: GiverAdded(indexed uint64,indexed address,string)
|
||||
handler: handleGiverAdded
|
||||
- event: GiverUpdated(indexed uint64,string)
|
||||
handler: handleGiverUpdated
|
||||
- event: DelegateAdded(indexed uint64,string)
|
||||
handler: handleDelegateAdded
|
||||
- event: DelegateUpdated(indexed uint64,string)
|
||||
handler: handleDelegateUpdated
|
||||
- event: ProjectAdded(indexed uint64,string)
|
||||
handler: handleProjectAdded
|
||||
- event: ProjectUpdated(indexed uint64,string)
|
||||
handler: handleProjectUpdated
|
||||
callHandlers:
|
||||
- function: addProject(string,string,address,uint64,uint64,address)
|
||||
handler: handleAddProject
|
||||
- function: updateProject(uint64,address,string,string,uint64)
|
||||
handler: handleUpdateProject
|
||||
- function: addGiver(address,string,string,uint64,address)
|
||||
handler: handleAddGiver
|
||||
- function: donate(uint64,uint64,address,uint256)
|
||||
handler: handleDonate
|
||||
file: ./src/mapping.ts
|
|
@ -0,0 +1,37 @@
|
|||
const Handlebars = require("handlebars");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const yaml = require("js-yaml");
|
||||
|
||||
const { t } = require("typy");
|
||||
|
||||
function getNetworkNameForSubgraph() {
|
||||
switch (process.env.SUBGRAPH) {
|
||||
case undefined:
|
||||
case "bgits/assemble":
|
||||
return "mainnet";
|
||||
case "bgits/liquid-funding-rinkeby":
|
||||
return "ropsten";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const networksFilePath = path.join(__dirname, "networks.yaml");
|
||||
const networks = yaml.load(await fs.readFile(networksFilePath, { encoding: "utf-8" }));
|
||||
|
||||
const networkName = process.env.NETWORK_NAME || getNetworkNameForSubgraph();
|
||||
const network = t(networks, networkName).safeObject;
|
||||
if (t(network).isFalsy) {
|
||||
throw new Error('Please set either a "NETWORK_NAME" or a "SUBGRAPH" environment variable');
|
||||
}
|
||||
|
||||
const subgraphTemplateFilePath = path.join(__dirname, "subgraph.template.yaml");
|
||||
const source = await fs.readFile(subgraphTemplateFilePath, "utf-8");
|
||||
const template = Handlebars.compile(source);
|
||||
const result = template(network);
|
||||
await fs.writeFile(path.join(__dirname, "subgraph.yaml"), result);
|
||||
|
||||
console.log("🎉 subgraph.yaml successfully generated");
|
||||
})();
|
Loading…
Reference in New Issue