Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: remove subgraph #36

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
BASESCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
ARBISCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# SUBGRAPH

## The Graph credentials
GRAPH_KEY="zzzzzzzzzzzz"

## Subgraph
SUBGRAPH_NAME="osx"
SUBGRAPH_VERSION="v1.0.0"
SUBGRAPH_NETWORK_NAME="mainnet" # ["mainnet", "sepolia", "polygon", "base", "arbitrum"]
4 changes: 0 additions & 4 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@
contracts:
- ./packages/contracts/**/*
- ./packages/contracts/*

subgraph:
- ./packages/subgraph/**/*
- ./packages/subgraph/*
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ See the framework lifecylce in `packages/contracts/docs/framework-lifecycle` to
- [ ] I have updated the `CHANGELOG.md` file in the root folder.
- [ ] I have updated the `DEPLOYMENT_CHECKLIST` file in the root folder.
- [ ] I have updated the `UPDATE_CHECKLIST` file in the root folder.
- [ ] I have updated the Subgraph and added a QA URL to the description of this PR.
3 changes: 0 additions & 3 deletions .github/workflows/formatting-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ jobs:

- name: 'Lint contracts ts and js'
run: 'yarn lint:contracts:ts'

- name: 'Lint subgraph ts and js'
run: 'yarn lint:subgraph:ts'
48 changes: 0 additions & 48 deletions .github/workflows/subgraph-tests.yml

This file was deleted.

9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ dist
node_modules
typechain

packages/subgraph/imported
packages/subgraph/generated
packages/subgraph/tests/.bin

docs

# files
Expand All @@ -22,8 +18,3 @@ docs
.DS_Store
.pnp.*
coverage.json

packages/subgraph/deploy-output.txt
packages/subgraph/subgraph.yaml
packages/subgraph/tests/.latest.json
packages/subgraph/tests/helpers/extended-schema.ts
99 changes: 0 additions & 99 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ The root folder of the repo includes two subfolders:
│ ├── ...
│ └── package.json
├── packages/subgraph
│ ├── src
│ ├── scripts
│ ├── manifest
│ ├── tests
│ ├── utils
│ ├── ...
│ └── package.json
├── ...
└── package.json
```
Expand Down Expand Up @@ -69,7 +60,6 @@ yarn lint
To be able to work on the contracts, make sure that you have created an `.env` file from the `.env.example` file and put in the API keys for

- [Alchemy](https://www.alchemy.com) that we use as the web3 provider
- [Alchemy Subgraphs](https://www.alchemy.com/subgraphs) that we use as the subgraph provider
- the block explorer that you want to use depending on the networks that you want to deploy to

Before deploying, you MUST also change the default hardhat private key (`PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"`).
Expand Down Expand Up @@ -224,95 +214,6 @@ This will upgrade your plugin repo to the latest Aragon OSx protocol version imp

Note, that if the deploying account doesn't own the repo anymore, this will create a `upgradeRepoProposalData-sepolia.json` containing the data for a management DAO signer to create a proposal upgrading the repo.

## Subgraph

### Installing

In `packages/subgraph`, first run

```sh
yarn install
```

which will also run

```sh
yarn postinstall
```

subsequently, to build the ABI in the `imported` folder.

### Building

Build the subgraph and

```sh
yarn build
```

which will first build the contracts (see [Contracts / Building](#building)) with

```
yarn build:contracts
```

second the subgraph manifest with

```sh
yarn build:manifest
```

and finally the subgraph itself with

```
yarn build:subgraph
```

When running `yarn build`, it requires a plugin address, which is obtained from the configuration file located
at `subgraph/manifest/data/<network>.json`, based on the network specified in your `.env` file under the `SUBGRAPH_NETWORK_NAME` variable.
You do not need to provide a plugin address for building or testing purposes, but it becomes necessary when deploying the subgraph.

During development of the subgraph, you might want to clean outdated files that were build, imported, and generated. To do this, run

```sh
yarn clean
```

### Testing

Test the subgraph with

```sh
yarn test
```

### Linting

Lint the TypeScript code with

```sh
yarn lint
```

### Coverage

Generate the code coverage with

```sh
yarn coverage
```

### Deployment

To deploy the subgraph to the subgraph provider, write your intended subgraph name and version into the `SUBGRAPH_NAME` and `SUBGRAPH_VERSION` variables [in the `.env` file that you created in the beginning](environment-variables) and pick a network name `SUBGRAPH_NETWORK_NAME` [being supported by the subgraph provider](https://docs.alchemy.com/reference/supported-subgraph-chains). Remember to place correctly the Plugin address on the network you are going to deploy to, you can do that by adding it on `subgraph/manifest/data/<network>.json`.
Then run

```sh
yarn deploy
```

to deploy the subgraph and check your [Alchemy subgraph dashboard](https://subgraphs.alchemy.com/onboarding) for completion and possible errors.

## License

This project is licensed under AGPL-3.0-or-later.
99 changes: 1 addition & 98 deletions USAGE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Template Usage Guide

This guide will walk you through the process of writing the smart contract for a plugin and also creating the subgraph. It will cover the following topics:
This guide will walk you through the process of writing the smart contract for a plugin. It will cover the following topics:

- [Dependency Installation](#dependency-installation)
- [Contracts](#contracts)
Expand All @@ -11,14 +11,6 @@ This guide will walk you through the process of writing the smart contract for a
- [Integration Testing](#integration-testing)
- [Deployment Scripts](#deployment-scripts)

- [Subgraph](#subgraph)
- [Included scripts and `.env` file](#included-scripts-and-env-file)
- [Creating a Subgraph](#creating-a-subgraph)
- [`manifest/subgraph.placeholder.yaml`](#manifestsubgraphplaceholderyaml)
- [`schema.graphql`](#schemagraphql)
- [Handlers](#handlers)
- [testing](#testing-1)

## Dependency Installation

Before you begin, make sure you installed the necessary dependencies.
Expand Down Expand Up @@ -107,92 +99,3 @@ The standard deploy scripts in the `packages/contracts/deploy` should already be
- Prints information on the used account's balance after deployment.
- `50_verification/51_verify_contracts.ts`
- Verifies all deployed contracts.

# Subgraph

## Included scripts and `.env` file

The current repo contains a set of 3 scripts to help you get started with your subgraph. These scripts are located in the `scripts` folder and are the following:

- `build-manifest.sh`: Builds the `subgraph.yaml` file from the `subgraph.template.yaml` file.
- `build-subgraph.sh`: Builds the subgraph from the `subgraph.yaml` file generated by the `build-manifest.sh` script.
- `deploy-subgraph.sh`: Deploys the subgraph.

These 3 scripts can be called with the `yarn` command:

```bash
# Build the subgraph.yaml file
yarn build:manifest
# Build the subgraph
yarn build:subgraph
# Deploy the subgraph
yarn deploy
```

**REMEMBER**: You need to build the contracts before building the subgraph. You can do that by running `yarn build:contracts`

If you use `yarn build` it will build the contracts, the subgraph.yaml file and the subgraph in that order.

This scripts depend on the `.env` file located in the root of the repo. This file contains some variables that are relevant for this scripts. The variables are the following:

```bash
# SUBGRAPH

## The Graph credentials
GRAPH_KEY="zzzzzzzzzzzz"

## Subgraph
SUBGRAPH_NAME="osx"
SUBGRAPH_VERSION="v1.0.0"
SUBGRAPH_NETWORK_NAME="mainnet" # ["mainnet", "sepolia", "polygon", "base", "arbitrum"]
```

- `GRAPH_KEY`: This key will be used for deploying the subgraph.
- `SUBGRAPH_NAME`: The name of the subgraph.
- `SUBGRAPH_VERSION`: The version of the subgraph.
- `SUBGRAPH_NETWORK_NAME`: The network where the subgraph will be deployed. This will be used for generating the subgraph.yaml file.

Editing this variables you can change how the subgraph is built and deployed.

## Creating a Subgraph

### `manifest/subgraph.placeholder.yaml`

The first step to create a subgraph is to create or edit the `subgraph.placeholder.yaml` file. This file is located in the `manifest` folder. This file contains the template for the `subgraph.yaml` file. This file is used by the `build-manifest.sh` script to generate the `subgraph.yaml` file. You can find more information about the `subgraph.yaml` file [here](https://thegraph.com/docs/define-a-subgraph#the-subgraph-manifest).

You will see that the `subgraph.placeholder.yaml` file contains some placeholders that will be replaced by the `build-manifest.sh` script. These placeholders are the following:

- `{{dataSources.PluginSetupProcessors}}`: The object containing the processors for the plugin setup events.
- `{{startBlock}}`: The block number where the subgraph will start indexing.
- `{{address}}`: The address of the contract that will be indexed.
- `{{network}}`: The network where the contract is deployed.

These placeholders are substituted using [mustache](https://mustache.github.io/).

The files containing the replacement values are stored in `manifest/data`. Here you can find a JSON file for each network. The name of the file is the name of the network. For example, the file for the mainnet network is `mainnet.json`. This file contains a property called `dataSources` which holds the information about the contract that will be indexed. In this case, we are only indexing one contract but you can index multiple contracts by adding more objects to the `dataSources` object.

### `schema.graphql`

The second step to create a subgraph is to define the schema. The schema is defined in the `schema.graphql` file located in the `subgraph` folder. This file contains the GraphQL schema that will be used for querying the subgraph. The schema is defined using the GraphQL Schema Definition Language (SDL). You can find more information about it [here](https://graphql.org/learn/schema/).

Here you can add your custom entities and how they are related to each other. You can find more information about the schema [here](https://thegraph.com/docs/define-a-subgraph#defining-the-schema).

## Handlers

Events handler functions are associated with the events in the `subgraph.yaml` file and defined in the `src` folder.

The `src` folder contains a `plugin` and `osx` subfolder.
In `plugin.ts` inside the `plugin` folder, you can add plugin-related event handlers.
In `pluginSetupProcessor.ts` inside the `osx` folder, you can add plugin-setup-processor-related event handlers that your plugin might require.

For the `MyPlugin` example, two handlers are already provided:

- `handleInstallationPrepared`: Handles the `InstallationPrepared` event. This event is emitted when the installation is prepared. This event contains the `installationId` and the handler will create a new `PluginEntity` entity with the `installationId` as the id.
- `handleNumberStored`: Handles the `NumberStored` event. And stores the number in the `pluginEntity` entity in the `number` property.

## Testing

This template uses [matchstick-as](https://github.com/LimeChain/matchstick) framework for unit testing.
Similar to the `src` folder, the `test` folder contains a `plugin` and `osx` subfolder, where the tests for the event handlers from the previous section are written.

In `plugin.test.ts` inside the `plugin` folder, you can test the plugin-related event handlers. In `pluginSetupProcessor.test.ts` inside the `osx` folder, you can test plugin-setup-processor-related event handlers that your plugin might require.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yml}\"",
"lint:contracts:sol": "solhint --max-warnings 0 \"packages/contracts/src/**/*.sol\"",
"lint:contracts:ts": "eslint --ext .js,.ts ./packages/contracts/",
"lint:subgraph:ts": "eslint --ext .js,.ts ./packages/subgraph/",
"lint": "yarn run lint:contracts:sol; yarn run lint:contracts:ts; yarn run lint:subgraph:ts"
"lint": "yarn run lint:contracts:sol; yarn run lint:contracts:ts"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
Expand Down
12 changes: 0 additions & 12 deletions packages/subgraph/.eslintrc.yml

This file was deleted.

12 changes: 0 additions & 12 deletions packages/subgraph/CHANGELOG.md

This file was deleted.

Loading
Loading