Skip to content

Commit

Permalink
The Graph (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Jul 1, 2024
1 parent 595aefb commit efcaee5
Show file tree
Hide file tree
Showing 18 changed files with 6,463 additions and 68 deletions.
23 changes: 23 additions & 0 deletions .github/actions/graph_prepare/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Prepare Graph environment"
description: "Set up Graph"
inputs:
working_directory:
description: "The working directory to run the commands in"
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Graph CLI
shell: bash
run: npm install -g @graphprotocol/graph-cli
- name: Install NPM modules
shell: bash
run: npm install
working-directory: ${{ inputs.working_directory }}
- name: Generate and build graph
shell: bash
run: npm run codegen && npm run build
working-directory: ${{ inputs.working_directory }}
23 changes: 23 additions & 0 deletions .github/workflows/graphs_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Graphs CI

on:
pull_request:
push:
branches: [main]
workflow_dispatch:

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
working-directory: [./graphs/omen-thumbnailmapping]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/foundry_prepare
- uses: ./.github/actions/graph_prepare
with:
working_directory: ${{ matrix.working-directory }}
- name: Run graph tests for ${{ matrix.working-directory }}
run: graph test -l -f
working-directory: ${{ matrix.working-directory }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiler files
cache/
out/
abi/

# Ignores development broadcast logs
!/broadcast
Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Repository holding the contracts made by Gnosis Labs team.

## Implemented contracts

| Contract Name | Description | Mainnet Address |
|----------------------------|-------------------------------------------------------|-------------------------------------------|
| OmenThumbnailMapping | Manages IPFS hashes for market thumbnails on Omen 2.0 | [0xe0cf08311F03850497B0ed6A2cf067f1750C3eFc](https://gnosisscan.io/address/0xe0cf08311f03850497b0ed6a2cf067f1750c3efc#code) |
| Contract Name | Description | Mainnet Address | TheGraph |
|----------------------------|-------------------------------------------------------|-------------------------------------------||-------------------------------------------|
| OmenThumbnailMapping | Manages IPFS hashes for market thumbnails on Omen 2.0 | [0xe0cf08311F03850497B0ed6A2cf067f1750C3eFc](https://gnosisscan.io/address/0xe0cf08311f03850497b0ed6a2cf067f1750c3efc#code) | [omen-thumbnailmapping](https://thegraph.com/studio/subgraph/omen-thumbnailmapping/) |


### Omen ThumbnailMapping

Contract used to store prediction market's address to IPFS hash of an image displayed on Omen 2.0

## Set up
## Set up contracts development

The repository uses [Foundry](https://book.getfoundry.sh/).

Expand Down Expand Up @@ -92,3 +92,23 @@ forge --help
anvil --help
cast --help
```

## Set up graph development

Graphs uses [The Graph](https://thegraph.com/docs).

### Installation

See installation instructions on https://thegraph.com/docs/en/developing/creating-a-subgraph/#install-the-graph-cli.

Then open directory of one of the graphs and run `npm install`.

### Build, test, deploy

Before working with graphs, you need to run `forge build` in the root directory.

- `omen-thumbnailmapping` - see `graphs/omen-thumbnailmapping/package.json`

The sequence of commands is `codegen -> build -> test -> deploy`.

(On MacOS Sonoma, running the tests in the docker mode is required: https://github.com/LimeChain/matchstick/issues/421)
64 changes: 0 additions & 64 deletions abi/omen_thumbnailmapping.abi.json

This file was deleted.

37 changes: 37 additions & 0 deletions graphs/omen-thumbnailmapping/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Graph CLI generated artifacts
build/
generated/

# Dependency directories
node_modules/
jspm_packages/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# dotenv environment variables file
.env

# Testing
coverage
coverage.json
.docker
.bin
data/

# Typechain
typechain
typechain-types

# Hardhat files
cache
50 changes: 50 additions & 0 deletions graphs/omen-thumbnailmapping/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"
services:
graph-node:
image: graphprotocol/graph-node
ports:
- "8000:8000"
- "8001:8001"
- "8020:8020"
- "8030:8030"
- "8040:8040"
depends_on:
- ipfs
- postgres
extra_hosts:
- host.docker.internal:host-gateway
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: "ipfs:5001"
ethereum: "mainnet:http://host.docker.internal:8545"
GRAPH_LOG: info
ipfs:
image: ipfs/kubo:v0.17.0
ports:
- "5001:5001"
volumes:
- ./data/ipfs:/data/ipfs
postgres:
image: postgres:14
ports:
- "5432:5432"
command:
[
"postgres",
"-cshared_preload_libraries=pg_stat_statements",
"-cmax_connections=200",
]
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
# FIXME: remove this env. var. which we shouldn't need. Introduced by
# <https://github.com/graphprotocol/graph-node/pull/3511>, maybe as a
# workaround for https://github.com/docker/for-mac/issues/6270?
PGDATA: "/var/lib/postgresql/data"
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
volumes:
- ./data/postgres:/var/lib/postgresql/data
8 changes: 8 additions & 0 deletions graphs/omen-thumbnailmapping/networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"gnosis": {
"Contract": {
"address": "0xe0cf08311f03850497b0ed6a2cf067f1750c3efc",
"startBlock": 34691500
}
}
}
Loading

0 comments on commit efcaee5

Please sign in to comment.