Skip to content

Commit

Permalink
style: use the guild's shared config for eslint and prettier (graphpr…
Browse files Browse the repository at this point in the history
…otocol#1031)

* add eslint and use the guild shared config

* prettier

* eslint

* node protocol for imports not ready yet
  • Loading branch information
enisdenjo authored Jan 13, 2023
1 parent 4c5e452 commit 71578d6
Show file tree
Hide file tree
Showing 127 changed files with 6,789 additions and 5,438 deletions.
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
dist
build
generated
packages/cli/tests/cli/init
packages/cli/tests/cli/validation

# TODO: cleanup examples and lint
examples
17 changes: 17 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: ['@theguild'],
rules: {
// not necessary here, we dont build with bob
'import/extensions': 'off',
// pushing to array multiple times is not a big deal
'unicorn/no-array-push-push': 'off',
// TODO: warning for now, clean up
'@typescript-eslint/no-this-alias': 'warn',
// TODO: remove default exports, breaking change?
'import/no-default-export': 'off',
// TODO: remove once we get rid of all anys
'@typescript-eslint/no-explicit-any': 'off',
// TODO: not ready yet
'unicorn/prefer-node-protocol': 'off',
},
};
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ blank_issues_enabled: false
contact_links:
- name: Have a question?
url: https://discord.gg/vtvv7FP
about: Not sure about something? need help from the community? have a question to our team? please ask and answer questions here.
about:
Not sure about something? need help from the community? have a question to our team? please
ask and answer questions here.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-store.outputs.PATH }}
key: ${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
key:
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
Expand Down Expand Up @@ -88,7 +90,9 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-store.outputs.PATH }}
key: ${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
key:
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-${{
hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-graphql-v${{ matrix.graphql-version }}-
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@theguild/prettier-config');
7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

15 changes: 10 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

Welcome to the Graph Protocol! Thanks a ton for your interest in contributing.

If you run into any problems feel free to create an issue. PRs are much appreciated for simple things. If it's something more complex we'd appreciate having a quick chat in GitHub Issues or Discord.
If you run into any problems feel free to create an issue. PRs are much appreciated for simple
things. If it's something more complex we'd appreciate having a quick chat in GitHub Issues or
Discord.

Join the conversation on our [Discord](https://discord.gg/9a5VCua).

Please follow the [Code of Conduct](https://github.com/graphprotocol/graph-node/blob/master/CODE_OF_CONDUCT.md) for all the communications and at events. Thank you!
Please follow the
[Code of Conduct](https://github.com/graphprotocol/graph-node/blob/master/CODE_OF_CONDUCT.md) for
all the communications and at events. Thank you!

## Commit messages

We use the following format for commit messages:
`{component-name}: {Brief description of changes}`, for example: `cli: Print stacktrace of codegen errors`.
We use the following format for commit messages: `{component-name}: {Brief description of changes}`,
for example: `cli: Print stacktrace of codegen errors`.

If multiple components are being changed list them all like this: `src/cli, src/runtime: Fix accessing EthereumEvent params`
If multiple components are being changed list them all like this:
`src/cli, src/runtime: Fix accessing EthereumEvent params`
43 changes: 18 additions & 25 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# NEWS

Note: This file only includes short summaries of the changes introduced in
each release. More detailed release notes can be found in the
[graph-node](https://github.com/graphprotocol/graph-node/tree/master/NEWS.md)
repo.
Note: This file only includes short summaries of the changes introduced in each release. More
detailed release notes can be found in the
[graph-node](https://github.com/graphprotocol/graph-node/tree/master/NEWS.md) repo.

## Unreleased

Expand All @@ -17,8 +16,7 @@ repo.
- Allow specifying a graft base in the manifest.
- Fix `Value is not a XYZ` errors for null values.
- Fix path lookups in compiler script (thanks @fubhy!).
- Add support for yarn workspaces and otherwise hoisted node modules (thanks
@fubhy!).
- Add support for yarn workspaces and otherwise hoisted node modules (thanks @fubhy!).
- Fix validating call handlers for functions with tuple parameters (#500).
- Properly unfold tuple event/call parameters in signatures.
- Pass `--debug` to AssemblyScript compiler.
Expand All @@ -28,13 +26,13 @@ repo.

### Feature: `graph test` (#414, #420, #421)

This release introduces a new `graph test` command that can be used to run
test commands against a (customizable) test environment (by default: Graph
Node, Postgres, IPFS and Ganache in Docker Compose).
This release introduces a new `graph test` command that can be used to run test commands against a
(customizable) test environment (by default: Graph Node, Postgres, IPFS and Ganache in Docker
Compose).

This essentially provides a framework for writing integration tests, where a
subgraph is indexed against a fresh Graph node, tests can wait for it to
synced, run queries at specific blocks and so on.
This essentially provides a framework for writing integration tests, where a subgraph is indexed
against a fresh Graph node, tests can wait for it to synced, run queries at specific blocks and so
on.

```
graph test [options] <test-command>
Expand All @@ -52,29 +50,24 @@ Options:
--node-logs Print the Graph Node logs (optional)
```

The `<test-command>` can be anything: it can be a shell script that builds
and deploys a subgraph, it can be a JS test suite run with Jest or it can be
a Truffle test suite, run with `truffle test`.
The `<test-command>` can be anything: it can be a shell script that builds and deploys a subgraph,
it can be a JS test suite run with Jest or it can be a Truffle test suite, run with `truffle test`.

Overriding the `--node-image` allows to use a custom build of Graph Node,
which is useful for running integration tests for specific versions of Graph
Node.
Overriding the `--node-image` allows to use a custom build of Graph Node, which is useful for
running integration tests for specific versions of Graph Node.

Overriding the `--compose-file` allows to e.g. use a different Ethereum
provider than the default Ganache, making it possible to test subgraphs
against mainnet for instance.
Overriding the `--compose-file` allows to e.g. use a different Ethereum provider than the default
Ganache, making it possible to test subgraphs against mainnet for instance.

### Misc

- Fix codegen for tuple arrays (#455 via #456). Thanks @JamesLefrere!
- Add `createWithContext()` code generation for data source templates (#446).
- Fix building in situations where `subgraph.yaml` is not in the working
directory (#443).
- Fix building in situations where `subgraph.yaml` is not in the working directory (#443).
- Add validation for new `@fulltext` directive (#433).
- Fix `URL` not being defined in older Node.js versions (#422).
- Add auto-migration from `apiVersion` 0.0.3 to 0.0.4 (#418).
- Fix Entity field getters for nullable fields (#417).
- Add support for overloaded Ethereum contract functions (#415).
- Update code generation to dedicated `ethereum` module in graph-ts (#409).
- Dependency updates: docker-compose, handlebars, jest, tern, keytar,
request.
- Dependency updates: docker-compose, handlebars, jest, tern, keytar, request.
55 changes: 39 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ As of today, the command line interface supports the following commands:
- `graph remove` — Unregisters a subgraph name with a Graph Node.
- `graph codegen` — Generates AssemblyScript types for smart contract ABIs and the subgraph schema.
- `graph build` — Compiles a subgraph to WebAssembly.
- `graph deploy` — Deploys a subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in the system's keychain.
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node) test environment (using Ganache by default).
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust binary in order to test a subgraph.
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other files - schema.graphql, abi and mapping.
- `graph deploy` — Deploys a subgraph to a
[Graph Node](https://github.com/graphprotocol/graph-node).
- `graph auth` — Stores a [Graph Node](https://github.com/graphprotocol/graph-node) access token in
the system's keychain.
- `graph local` — Runs tests against a [Graph Node](https://github.com/graphprotocol/graph-node)
test environment (using Ganache by default).
- `graph test` — Downloads and runs the [Matchstick](https://github.com/LimeChain/matchstick) rust
binary in order to test a subgraph.
- `graph add` - Adds a new datasource to the yaml file and writes the necessary changes to other
files - schema.graphql, abi and mapping.

## How It Works

Expand All @@ -26,7 +31,9 @@ The Graph CLI takes a subgraph manifest (defaults to `subgraph.yaml`) with refer
- Smart contract ABIs, and
- Mappings written in AssemblyScript.

It compiles the mappings to WebAssembly, builds a ready-to-use version of the subgraph saved to IPFS or a local directory for debugging, and deploys the subgraph to a [Graph Node](https://github.com/graphprotocol/graph-node).
It compiles the mappings to WebAssembly, builds a ready-to-use version of the subgraph saved to IPFS
or a local directory for debugging, and deploys the subgraph to a
[Graph Node](https://github.com/graphprotocol/graph-node).

## Installation

Expand All @@ -42,24 +49,34 @@ yarn global add @graphprotocol/graph-cli

### On Linux

`libsecret` is used for storing access tokens, so you may need to install it before getting started. Use one of the following commands depending on your distribution:
`libsecret` is used for storing access tokens, so you may need to install it before getting started.
Use one of the following commands depending on your distribution:

- Debian/Ubuntu: `sudo apt-get install libsecret-1-dev`
- Red Hat: `sudo yum install libsecret-devel`
- Arch Linux: `sudo pacman -S libsecret`

## Getting Started

The Graph CLI can be used with a local or self-hosted [Graph Node](https://github.com/graphprotocol/graph-node) or with the [Hosted Service](https://thegraph.com/explorer/). To help you get going, there are [quick start guides](https://thegraph.com/docs/en/developer/quick-start/) available for both.
The Graph CLI can be used with a local or self-hosted
[Graph Node](https://github.com/graphprotocol/graph-node) or with the
[Hosted Service](https://thegraph.com/explorer/). To help you get going, there are
[quick start guides](https://thegraph.com/docs/en/developer/quick-start/) available for both.

If you are ready to dive into the details of building a subgraph from scratch, there is a [detailed walkthrough](https://thegraph.com/docs/en/developer/create-subgraph-hosted/) for that as well, along with API documentation for the [AssemblyScript API](https://thegraph.com/docs/en/developer/assemblyscript-api/).
If you are ready to dive into the details of building a subgraph from scratch, there is a
[detailed walkthrough](https://thegraph.com/docs/en/developer/create-subgraph-hosted/) for that as
well, along with API documentation for the
[AssemblyScript API](https://thegraph.com/docs/en/developer/assemblyscript-api/).

## Release process

We use `changeset` to manage releases. Every PR should include a changeset file. The release process is as follows:
We use `changeset` to manage releases. Every PR should include a changeset file. The release process
is as follows:

1. Author creates the PR with changes and runs `pnpm changeset` to create a changeset file to summarize the changes.
2. When the PR is merged to `main`, a Github Action will run and create a PR with the version bump and changelog.
1. Author creates the PR with changes and runs `pnpm changeset` to create a changeset file to
summarize the changes.
2. When the PR is merged to `main`, a Github Action will run and create a PR with the version bump
and changelog.
3. We will merge the bot generated PR to `main`.
4. A Github Action will run and publish the new version to npm.

Expand All @@ -71,20 +88,26 @@ Helpful links:

### Stable release example

When PRs are merged and to `main` we can choose to merge the bot generated changeset PR to `main` and it will publish a new version to npm.
When PRs are merged and to `main` we can choose to merge the bot generated changeset PR to `main`
and it will publish a new version to npm.

Example of a `graph-client` release: https://github.com/graphprotocol/graph-client/pull/295

### Alpha release example

Every PR to `main` that includes a changeset file will create a new alpha version.

Example of `graph-client` snapshot release: https://github.com/graphprotocol/graph-client/pull/178#issuecomment-1214822036
Example of `graph-client` snapshot release:
https://github.com/graphprotocol/graph-client/pull/178#issuecomment-1214822036

## License

Copyright &copy; 2018-2019 Graph Protocol, Inc. and contributors.

The Graph CLI is dual-licensed under the [MIT license](LICENSE-MIT) and the [Apache License, Version 2.0](LICENSE-APACHE).
The Graph CLI is dual-licensed under the [MIT license](LICENSE-MIT) and the
[Apache License, Version 2.0](LICENSE-APACHE).

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
implied. See the License for the specific language governing permissions and limitations under the
License.
3 changes: 2 additions & 1 deletion examples/basic-event-handlers/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Example Subgraph

An example to help you get started with The Graph. For more information see the docs on https://thegraph.com/docs/.
An example to help you get started with The Graph. For more information see the docs on
https://thegraph.com/docs/.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Migrations = artifacts.require('./Migrations.sol')
var Migrations = artifacts.require('./Migrations.sol');

module.exports = function (deployer) {
deployer.deploy(Migrations)
}
deployer.deploy(Migrations);
};
6 changes: 3 additions & 3 deletions examples/basic-event-handlers/migrations/2_deploy_contract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');

module.exports = async function (deployer) {
await deployer.deploy(GravatarRegistry)
}
await deployer.deploy(GravatarRegistry);
};
14 changes: 7 additions & 7 deletions examples/basic-event-handlers/migrations/3_create_gravatars.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');

module.exports = async function (deployer) {
let accounts = await web3.eth.getAccounts()
const accounts = await web3.eth.getAccounts();

const registry = await GravatarRegistry.deployed()
await registry.setMythicalGravatar({ from: accounts[0] })
const registry = await GravatarRegistry.deployed();
await registry.setMythicalGravatar({ from: accounts[0] });
await registry.createGravatar('Carl', 'https://thegraph.com/img/team/team_04.png', {
from: accounts[0],
})
});
await registry.createGravatar('Lucas', 'https://thegraph.com/img/team/bw_Lucas.jpg', {
from: accounts[1],
})
}
});
};
12 changes: 6 additions & 6 deletions examples/basic-event-handlers/migrations/4_update_gravatars.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol')
const GravatarRegistry = artifacts.require('./GravatarRegistry.sol');

module.exports = async function (deployer) {
let accounts = await web3.eth.getAccounts()
const accounts = await web3.eth.getAccounts();

const registry = await GravatarRegistry.deployed()
await registry.updateGravatarName('Nena', { from: accounts[0] })
await registry.updateGravatarName('Jorge', { from: accounts[1] })
}
const registry = await GravatarRegistry.deployed();
await registry.updateGravatarName('Nena', { from: accounts[0] });
await registry.updateGravatarName('Jorge', { from: accounts[1] });
};
16 changes: 8 additions & 8 deletions examples/basic-event-handlers/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "basic-event-handlers",
"private": true,
"version": "0.1.0",
"private": true,
"scripts": {
"codegen": "../../packages/cli/dist/bin.js codegen",
"build": "../../packages/cli/dist/bin.js build",
"test": "docker compose up -d && sleep 30 && truffle test --network test && docker compose down",
"codegen": "../../packages/cli/dist/bin.js codegen",
"create-test": "../../packages/cli/dist/bin.js create test/basic-event-handlers --node http://127.0.0.1:18020",
"deploy-test": "../../packages/cli/dist/bin.js deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020"
},
"devDependencies": {
"@graphprotocol/graph-ts": "0.29.1",
"apollo-fetch": "^0.7.0"
"deploy-test": "../../packages/cli/dist/bin.js deploy test/basic-event-handlers --version-label v0.0.1 --ipfs http://localhost:15001 --node http://127.0.0.1:18020",
"test": "docker compose up -d && sleep 30 && truffle test --network test && docker compose down"
},
"dependencies": {
"babel-polyfill": "6.26.0",
"babel-register": "6.26.0",
"truffle": "5.0.12",
"truffle-hdwallet-provider": "1.0.6"
},
"devDependencies": {
"@graphprotocol/graph-ts": "0.29.1",
"apollo-fetch": "^0.7.0"
},
"resolutions": {
"assemblyscript": "0.19.10"
}
Expand Down
Loading

0 comments on commit 71578d6

Please sign in to comment.