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

Update readme for dufour channels #360

Open
wants to merge 1 commit into
base: main
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
87 changes: 24 additions & 63 deletions subgraph/packages/subgraph-dufour-channel/README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,34 @@
# Subgraph for HoprChannels

This subgraph gets updated to index the latest production HOPR network.
Currently it's deployed for "Dufour" network.

## How to run
## Development
1. Install

Here's the _tl;dr_ version:

```bash
// Using hoprnet/hoprnet
$ yarn run:network
// Inside this repo
$ pbpaste | xargs -I {} echo "ETHEREUM_NETWORK=localhost\nETHEREUM_ENDPOINT={}" > .env
$ yarn prepare-local
$ yarn codegen
$ yarn pre-build
$ yarn build
$ docker-compose up
$ yarn create-local
$ yarn deploy-local
// Back to hoprnet/hoprnet
$ DEBUG=hopr* yarn run:hoprd:alice
$ yarn run:faucet:alice
```sh
yarn install && yarn codegen
export DUFOUR_SUBGRAPH_NAME=hopr-channels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there already a subgraph called "hopr-channels" that is deployed ?

```
### 1. Run local network
First, make sure you are running [hoprnet/hoprnet](https://github.com/hoprnet/hoprnet)
local network via `yarn run:network`. Update your `.env` with your network address,
likely `http://localhost:8545` within your workstation, or a public URL like
`https://8545-amber-cod-wcakvqd8.ws-eu11.gitpod.io/` if you are using Gitpod.

### 2. Update graph configuration for local use

Run `yarn prepare-local` so your `subgraph.yaml` is automatically generated for local
use with the adequate configuration.

### 3. Generate the graph web assembly code

Run `yarn codegen` which will parse your `subgraph.yaml` file
into types ready to be imported for your `mappings.ts`. You
are now ready to modify your `mappings.ts` as needed based on
the handlers you described previously in your graph.

### 4. Build your project mappings into wasm

Run `yarn build`, which will compile everything for the
`graph-node` to use in `wasm` format. Any AssemblyScript
errors will be shown there.

### 5. Start Subgraph node via docker-compose
2. Create a project in Subgraph studio, if not done

Since a subgraph relies on an IPFS daemon and a PostgreSQL database to run, we
will now run `docker-compose up` to kickstart the adequate services. This data
will be stored locally under your `./data` folder.

If you find any errors, you can always `rm -rf data` to restart the bootstrap
process and interact with the ethereum network. This is likely in the case of
long running nodes.

### 6. Create subgraph configuration in local node

Run `yarn create-local` to deploy your subgraph configuration to the local
graph node, which should be shown in your logs.

### 7. Deploy your subgraph configuraiton
```sh
npx graph init --studio $DUFOUR_SUBGRAPH_NAME
npx graph auth --studio
```

Run `yarn deploy-local` to deploy your actual subgraph mappings code to the
local graph node, which will start fetching events from your network. You will
see a URL available under `${url}/subgraphs/name/hoprnet/hopr-channels/graphql`
3. Build the subgraph
```sh
yarn build
```

### 8. Interact with your network to allow event fetching
4. Deploy to Subgraph Studio
```sh
npx graph deploy --studio $DUFOUR_SUBGRAPH_NAME
```

From the `hoprnet/hoprnet` project, start running nodes in the network to see
events showing up in your query indexer. Go to your GraphQLi instance to start
interacting with your GraphQL endpoint via queries.
## Deployment
- Deployment ID: QmNSBAgoudxv5Qk9Yj16yz9U8MPbiSTUfjQi4njAuNksBu
- Query: https://gateway.thegraph.com/api/[api-key]/subgraphs/id/Feg6Jero3aQzesVYuqk253NNLyNAZZppbDPKFYEGJ1Hj
- Explorer: https://thegraph.com/explorer/subgraphs/Feg6Jero3aQzesVYuqk253NNLyNAZZppbDPKFYEGJ1Hj?view=Overview&chain=mainnet
5 changes: 2 additions & 3 deletions subgraph/packages/subgraph-dufour-channel/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "hopr-dufour-channels",
"name": "hopr-channels",
"license": "UNLICENSED",
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"deploy": "graph deploy --debug --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ hoprnet/hopr-dufour-channels",
"deploy": "graph deploy --debug --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ hoprnet/hopr-channels",
"test": "graph test -d"
},
"dependencies": {
Expand All @@ -14,7 +14,6 @@
"mustache": "^4.2.0"
},
"devDependencies": {
"@hoprnet/hopr-ethereum": "latest",
"@types/node": "^18.0.0",
"matchstick-as": "^0.6.0",
"ts-node": "^10.2.1",
Expand Down