Skip to content

KlimaDAO/klima-subgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KlimaDAO Protocol Subgraphs

The main subgraph repo that houses all of the data associated with the KlimaDAO protocol (except the tokenized carbon subgraphs which live here).

Local development & testing

  1. npm install from root to fetch dependencies
  2. Review the Unit Testing Guide to get any missing deps for WSL/Linux/MacOS

Local Installation

First, deploy a Graph node locally. The most straightforward option is to use docker-compose from the graph-node repo. Make sure to update the ethereum environment variable of graph-node in docker/docker-compose.yml to matic:https://polygon-rpc.com/.

For information on getting started with a Graph Node see this link: https://github.com/graphprotocol/graph-node/blob/master/docs/getting-started.md

Install any needed packages.

# from root
npm install

Create the subgraph instance. Use -w {workspace_name}.

npm run -w polygon-digital-carbon create-local

Finally run codegen and deploy the subgraph and start indexing.

npm run -w polygon-digital-carbon codegen && npm run -w polygon-digital-carbon deploy-local

Local Navigation and Querying

After the subgraph is deployed, navigate to http://127.0.01:8000/subgraphs/name/name-of-subgraph. You can then create GraphQL queries and view the returned data.

Deployed Hosted Service Subgraphs

Add credits definitions on the fly

Adding credits definitions normally requires updating the lib/projects/Projects.ts file and recompiling and redeploying the Marketplace and Polygon Digital Carbon subgraphs. This process is not optimal because the subgraphs deployments are tedious and long.

Projects can be added on the fly (without redeploying the contracts) by updating the CreditManager contract.

  • update the lib/projects/Projects.ts file with the new project's definitions
  • set your ALCHEMY_API_KEY environment variable
  • set your PRIVATE_KEY environment variable
  • execute npm run addCredits-polygon <creditId>

Subgraph deployments

Deployment

To deploy a new subgraph version:

  • Make the desired changes to the subgraph source files
  • Update the subgraph version with npm version patch for instance. The deployment script will not deployed subgraph whose version has not changed even if the source code was updated.
  • Make a pull request against the main branch
  • Once merged the github workflow will deploy the subgraph on both The Graph Studio and Goldsky See the deployment script: https://github.com/KlimaDAO/klima-subgraph/blob/main/.github/workflows/deploy.yaml

Promotion

Once the new versions of the subgraph have been deployed and synced, you have to promote them

The Graph studio

  1. Connect to the Graph studio using the multisig wallet
  2. Select the subgraph
  3. Select the version
  4. Click on publish
  5. Confirm the publication
  6. Have another signer confirm the transaction in the safe

Goldsky

  1. Connect to Goldsky
  2. Select the subgraph
  3. Select the version
  4. Click on Add tag
  5. Add the tag 'latest'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 10