Activate dependabot, build tweaks, green CI (#6)

* activate dependabot

* package updates

* move auto-generated typings, adapt .gitignore

* lint fix

* eslint config tweaks, turn off eqeqeq rule

* kick out Travis, switch to GitHub Actions

* Update the readme file.

* Add totalOceanLiquidity and fix TVL calculation

* add logs to track pool shares.

* lockedValue fix

* update variable names

* Feature/devel instructions (#19)

* improve developer docs

* fix readme

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* update gitignore

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* .env, and infura key

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* merged/dependabot-tvl-fix (#21)

* Update the readme file.

* Add totalOceanLiquidity and fix TVL calculation

* add logs to track pool shares.

* update variable names

* fix error after merge

Co-authored-by: ssallam <travis@travis-ci.org>

* use const

Co-authored-by: ssallam <travis@travis-ci.org>
Co-authored-by: Alex Coseru <alex.coseru@gmail.com>
Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
Co-authored-by: Samer <36411297+ssallam@users.noreply.github.com>
This commit is contained in:
Matthias Kretschmann 2021-02-09 11:13:31 +01:00 committed by GitHub
parent 30f71367f7
commit f1a8269036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 741 additions and 158 deletions

View File

@ -5,17 +5,14 @@
}, },
"extends": [ "extends": [
"oceanprotocol", "oceanprotocol",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended", "prettier",
"prettier/react",
"prettier/standard",
"prettier/@typescript-eslint" "prettier/@typescript-eslint"
], ],
"plugins": ["@typescript-eslint", "prettier"], "plugins": ["@typescript-eslint"],
"rules": { "rules": {
"no-use-before-define": "off", "no-use-before-define": "off",
"eqeqeq": "off",
"@typescript-eslint/no-use-before-define": "error" "@typescript-eslint/no-use-before-define": "error"
}, }
"env": { "es6": true, "node": true }
} }

8
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
time: '03:00'
timezone: Europe/Berlin

36
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: 'CI'
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
# TODO: activate once this issue is solved:
# https://github.com/graphprotocol/graph-ts/issues/113
# - run: npm run type-check
- run: npm run codegen
- run: npm run build

8
.gitignore vendored
View File

@ -1,3 +1,6 @@
src/@types
build
# Logs # Logs
logs logs
*.log *.log
@ -10,6 +13,9 @@ pids
*.pid *.pid
*.seed *.seed
*.pid.lock *.pid.lock
/docker/data
/src/types
# Directory for instrumented libs generated by jscoverage/JSCover # Directory for instrumented libs generated by jscoverage/JSCover
lib-cov lib-cov
@ -30,7 +36,7 @@ bower_components
.lock-wscript .lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html) # Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release build
# Dependency directories # Dependency directories
node_modules/ node_modules/

View File

@ -1,12 +0,0 @@
language: node_js
node_js: node
script:
# will run `npm ci` automatically here
- npm run lint
# TODO: activate once this issue is solved:
# https://github.com/graphprotocol/graph-ts/issues/113
# - npm run type-check
notifications:
email: false

View File

@ -4,7 +4,7 @@
> 🦀 Ocean Protocol Subgraph > 🦀 Ocean Protocol Subgraph
[![Build Status](https://travis-ci.com/oceanprotocol/ocean-subgraph.svg?branch=main)](https://travis-ci.com/oceanprotocol/ocean-subgraph) [![Build Status](https://github.com/oceanprotocol/ocean-subgraph/workflows/CI/badge.svg)](https://github.com/oceanprotocol/ocean-subgraph/actions)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol) [![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
- [🏄 Get Started](#-get-started) - [🏄 Get Started](#-get-started)
@ -75,58 +75,27 @@ This subgraph is deployed for all networks the Ocean Protocol contracts are depl
## 🦑 Development ## 🦑 Development
Prepare the docker setup:
```bash ```bash
npm i cd docker
```
- Install/run the Graph: `https://thegraph.com/docs/quick-start`
- You can skip running ganache-cli and connect directly to `mainnet` using Infura
```bash
git clone https://github.com/graphprotocol/graph-node/
cd graph-node/docker
./setup.sh ./setup.sh
# Update this line in the `docker-compose.yml` file with your Infura ProjectId ```
# ethereum: 'mainnet:https://mainnet.infura.io/v3/INFURA_PROJECT_ID' Edit docker-compose and add your infura key & network
Start :
```bash
docker-compose up docker-compose up
``` ```
To use with ifura key create a .env file (look at .env.example)
Note: making contract calls using Infura fails with `missing trie node` errors. The fix requires editing `ethereum_adapter.rs` line 434 to use the latest block instead of a specific block number. Replace: `web3.eth().call(req, Some(block_id)).then(|result| {` with `web3.eth().call(req, Some(BlockNumber::Latest.into())).then(|result| {`
To run the graph-node with this fix it must be run from source.
First, delete the `graph-node` container from the `docker-compose.yml` file
then run `docker-compose up` to get the postgresql and ipfs services running.
Now you can build and run the graph-node from source
```
cargo run -p graph-node --release > graphnode.log --
--postgres-url postgres://graph-node:let-me-in@localhost:5432/graph-node
--ethereum-rpc mainnet:https://mainnet.infura.io/v3/INFURA_PROJECT_ID
--ipfs 127.0.0.1:5001
```
- Once the graph node is ready, do the following to deploy the ocean-subgraph to the local graph-node
```bash ```bash
git clone https://github.com/oceanprotocol/ocean-subgraph/ docker-compose --env-file .env up
cd ocean-subgraph
npm i
npm run codegen
npm run create:local
npm run deploy:local
``` ```
- You can edit the event handler code and then run `npm run deploy:local` Switch to a new terminal:
- Running deploy will fail if the code has no changes
- Sometimes deploy will fail no matter what, in this case: To deploy the ocean-subgraph to graph-node, see the `Deployment` section below.
- Stop the docker-compose run (`docker-compose down`)
- Delete the `ipfs` and `postgres` folders in `graph-node/docker/data` You can make changes to the event handlers and/or features and re-deploy, again see the `Deployment` section below.
- Restart docker-compose
- Run `npm run create:local` to create the ocean-subgraph
- Run `npm run deploy:local` to deploy the ocean-subgraph
## ✨ Code Style ## ✨ Code Style
@ -142,7 +111,9 @@ npm run format
## ⬆️ Releases ## ⬆️ Releases
Releases are managed semi-automatically. They are always manually triggered from a developer's machine with release scripts. From a clean `main` branch you can run the release task bumping the version accordingly based on semantic versioning: Releases are managed semi-automatically. They are always manually triggered from a developer's
machine with release scripts. From a clean `main` branch you can run the release task bumping
the version accordingly based on semantic versioning:
```bash ```bash
npm run release npm run release
@ -162,6 +133,32 @@ For the GitHub releases steps a GitHub personal access token, exported as `GITHU
## 🛳 Production ## 🛳 Production
## ⬆️ Deployment ## ⬆️ Deployment
- Do the following to deploy the ocean-subgraph to a graph-node running locally:
```bash
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
npm run codegen
npm run create:local
npm run deploy:local
```
The above will deploy ocean-subgraph connecting to mainnet. To create/deploy subgraph connecting to Rinkeby or Ropsten test net,
use :local-rinkeby or :local-ropsten with either create or deploy command.
- You can edit the event handler code and then run `npm run deploy:local`
- Running deploy will fail if the code has no changes
- Sometimes deploy will fail no matter what, in this case:
- Stop the docker-compose run (`docker-compose down` or Ctrl+C)
This should stop the graph-node, ipfs and postgres containers
- Delete the `ipfs` and `postgres` folders in `/docker/data` (`rm -rf ./docker/data/*`)
- Run `docker-compose up` to restart graph-node, ipfs and postgres
- Run `npm run create:local` to create the ocean-subgraph
- Run `npm run deploy:local` to deploy the ocean-subgraph
Note: to deploy to one of the remote nodes run by Ocean, you can do port-forwarding then using the
above `local` create/deploy commands will work as is.
## 🏛 License ## 🏛 License

1
docker/.env.example Normal file
View File

@ -0,0 +1 @@
INFURA_PROJECT_ID="xxx"

80
docker/README.md Normal file
View File

@ -0,0 +1,80 @@
# Graph Node Docker Image
Preconfigured Docker image for running a Graph Node.
## Usage
```sh
docker run -it \
-e postgres_host=<HOST> \
-e postgres_port=<PORT> \
-e postgres_user=<USER> \
-e postgres_pass=<PASSWORD> \
-e postgres_db=<DBNAME> \
-e ipfs=<HOST>:<PORT> \
-e ethereum=<NETWORK_NAME>:<ETHEREUM_RPC_URL> \
graphprotocol/graph-node:latest
```
### Example usage
```sh
docker run -it \
-e postgres_host=host.docker.internal \
-e postgres_port=5432 \
-e postgres_user=graph-node \
-e postgres_pass=oh-hello \
-e postgres_db=graph-node \
-e ipfs=host.docker.internal:5001 \
-e ethereum=mainnet:http://localhost:8545/ \
graphprotocol/graph-node:latest
```
## Docker Compose
The Docker Compose setup requires an Ethereum network name and node
to connect to. By default, it will use `mainnet:http://host.docker.internal:8545`
in order to connect to an Ethereum node running on your host machine.
You can replace this with anything else in `docker-compose.yaml`.
> **Note for Linux users:** On Linux, `host.docker.internal` is not
> currently supported. Instead, you will have to replace it with the
> IP address of your Docker host (from the perspective of the Graph
> Node container).
> To do this, run:
>
> ```
> CONTAINER_ID=$(docker container ls | grep graph-node | cut -d' ' -f1)
> docker exec $CONTAINER_ID /bin/bash -c 'apt install -y iproute2 && ip route' | awk '/^default via /{print $3}'
> ```
>
> This will print the host's IP address. Then, put it into `docker-compose.yml`:
>
> ```
> sed -i -e 's/host.docker.internal/<IP ADDRESS>/g' docker-compose.yml
> ```
After you have set up an Ethereum node—e.g. Ganache or Parity—simply
clone this repository and run
```sh
docker-compose up
```
This will start IPFS, Postgres and Graph Node in Docker and create persistent
data directories for IPFS and Postgres in `./data/ipfs` and `./data/postgres`. You
can access these via:
- Graph Node:
- GraphiQL: `http://localhost:8000/`
- HTTP: `http://localhost:8000/subgraphs/name/<subgraph-name>`
- WebSockets: `ws://localhost:8001/subgraphs/name/<subgraph-name>`
- Admin: `http://localhost:8020/`
- IPFS:
- `127.0.0.1:5001` or `/ip4/127.0.0.1/tcp/5001`
- Postgres:
- `postgresql://graph-node:let-me-in@localhost:5432/graph-node`
Once this is up and running, you can use
[`graph-cli`](https://github.com/graphprotocol/graph-cli) to create and
deploy your subgraph to the running Graph Node.

11
docker/bin/create Executable file
View File

@ -0,0 +1,11 @@
#! /bin/bash
if [ $# != 1 ]; then
echo "usage: create <name>"
exit 1
fi
api="http://index-node.default/"
data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_create", "params": {"name":"%s"}, "id":"1"}' "$1")
curl -s -H "content-type: application/json" --data "$data" "$api"

9
docker/bin/debug Executable file
View File

@ -0,0 +1,9 @@
#! /bin/bash
if [ -f "$1" ]
then
exec rust-gdb -c "$1" /usr/local/cargo/bin/graph-node
else
echo "usage: debug <core-file>"
exit 1
fi

12
docker/bin/deploy Executable file
View File

@ -0,0 +1,12 @@
#! /bin/bash
if [ $# != 3 ]; then
echo "usage: deploy <name> <ipfs_hash> <node>"
exit 1
fi
api="http://index-node.default/"
echo "Deploying $1 (deployment $2)"
data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_deploy", "params": {"name":"%s", "ipfs_hash":"%s", "node_id":"%s"}, "id":"1"}' "$1" "$2" "$3")
curl -s -H "content-type: application/json" --data "$data" "$api"

12
docker/bin/reassign Executable file
View File

@ -0,0 +1,12 @@
#! /bin/bash
if [ $# -lt 3 ]; then
echo "usage: reassign <name> <ipfs_hash> <node>"
exit 1
fi
api="http://index-node.default/"
echo Assigning to "$3"
data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_reassign", "params": {"name":"%s", "ipfs_hash":"%s", "node_id":"%s"}, "id":"1"}' "$1" "$2" "$3")
curl -s -H "content-type: application/json" --data "$data" "$api"

11
docker/bin/remove Executable file
View File

@ -0,0 +1,11 @@
#! /bin/bash
if [ $# != 1 ]; then
echo "usage: create <name>"
exit 1
fi
api="http://index-node.default/"
data=$(printf '{"jsonrpc": "2.0", "method": "subgraph_remove", "params": {"name":"%s"}, "id":"1"}' "$1")
curl -s -H "content-type: application/json" --data "$data" "$api"

38
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,38 @@
version: '3'
services:
graph-node:
image: oceanprotocol/graph-node:latest
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
depends_on:
- ipfs
- postgres
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'rinkeby:https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}'
RUST_LOG: info
ipfs:
image: ipfs/go-ipfs:v0.4.23
ports:
- '5001:5001'
volumes:
- ./data/ipfs:/data/ipfs
postgres:
image: postgres
ports:
- '5432:5432'
command: ['postgres', '-cshared_preload_libraries=pg_stat_statements']
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
volumes:
- ./data/postgres:/var/lib/postgresql/data

8
docker/hooks/post_checkout Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
set -x
echo "Setting SOURCE_BRANCH to ${SOURCE_BRANCH}"
sed -i "s@^ENV SOURCE_BRANCH \"master\"@ENV SOURCE_BRANCH \"${SOURCE_BRANCH}\"@g" Dockerfile

42
docker/setup.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -e
if ! which docker 2>&1 > /dev/null; then
echo "Please install 'docker' first"
exit 1
fi
if ! which docker-compose 2>&1 > /dev/null; then
echo "Please install 'docker-compose' first"
exit 1
fi
if ! which jq 2>&1 > /dev/null; then
echo "Please install 'jq' first"
exit 1
fi
# Create the graph-node container
docker-compose up --no-start graph-node
# Start graph-node so we can inspect it
docker-compose start graph-node
# Identify the container ID
CONTAINER_ID=$(docker container ls | grep graph-node | cut -d' ' -f1)
# Inspect the container to identify the host IP address
HOST_IP=$(docker inspect "$CONTAINER_ID" | jq -r .[0].NetworkSettings.Networks[].Gateway)
echo "Host IP: $HOST_IP"
# Inject the host IP into docker-compose.yml
sed -i -e "s/host.docker.internal/$HOST_IP/g" docker-compose.yml
function stop_graph_node {
# Ensure graph-node is stopped
docker-compose stop graph-node
}
trap stop_graph_node EXIT

111
docker/start Executable file
View File

@ -0,0 +1,111 @@
#!/bin/bash
save_coredumps() {
graph_dir=/var/lib/graph
datestamp=$(date +"%Y-%m-%dT%H:%M:%S")
ls /core.* >& /dev/null && have_cores=yes || have_cores=no
if [ -d "$graph_dir" -a "$have_cores" = yes ]
then
core_dir=$graph_dir/cores
mkdir -p $core_dir
exec >> "$core_dir"/messages 2>&1
echo "${HOSTNAME##*-} Saving core dump on ${HOSTNAME} at ${datestamp}"
dst="$core_dir/$datestamp-${HOSTNAME}"
mkdir "$dst"
cp /usr/local/bin/graph-node "$dst"
cp /proc/loadavg "$dst"
[ -f /Dockerfile ] && cp /Dockerfile "$dst"
tar czf "$dst/etc.tgz" /etc/
dmesg -e > "$dst/dmesg"
# Capture environment variables, but filter out passwords
env | sort | sed -r -e 's/^(postgres_pass|ELASTICSEARCH_PASSWORD)=.*$/\1=REDACTED/' > "$dst/env"
for f in /core.*
do
echo "${HOSTNAME##*-} Found core dump $f"
mv "$f" "$dst"
done
echo "${HOSTNAME##*-} Saving done"
fi
}
wait_for_ipfs() {
# Take the IPFS URL in $1 apart and extract host and port. If no explicit
# host is given, use 443 for https, and 80 otherwise
if [[ "$1" =~ ^((https?)://)?([^:/]+)(:([0-9]+))? ]]
then
proto=${BASH_REMATCH[2]:-http}
host=${BASH_REMATCH[3]}
port=${BASH_REMATCH[5]}
if [ -z "$port" ]
then
[ "$proto" = "https" ] && port=443 || port=80
fi
wait_for "$host:$port" -t 120
else
echo "invalid IPFS URL: $1"
exit 1
fi
}
start_query_node() {
export DISABLE_BLOCK_INGESTOR=true
graph-node \
--postgres-url "$postgres_url" \
--ethereum-rpc $ethereum \
--ipfs "$ipfs"
}
start_index_node() {
# Only the index node with the name set in BLOCK_INGESTOR should ingest
# blocks
if [[ ${node_id} != "${BLOCK_INGESTOR}" ]]; then
export DISABLE_BLOCK_INGESTOR=true
fi
graph-node \
--node-id "${node_id//-/_}" \
--postgres-url "$postgres_url" \
--ethereum-rpc $ethereum \
--ipfs "$ipfs"
}
start_combined_node() {
graph-node \
--postgres-url "$postgres_url" \
--ethereum-rpc $ethereum \
--ipfs "$ipfs"
}
postgres_port=${postgres_port:-5432}
postgres_url="postgresql://$postgres_user:$postgres_pass@$postgres_host:$postgres_port/$postgres_db"
wait_for_ipfs "$ipfs"
wait_for "$postgres_host:$postgres_port" -t 120
sleep 5
trap save_coredumps EXIT
export PGAPPNAME="${node_id-$HOSTNAME}"
# Set custom poll interval
if [ -n "$ethereum_polling_interval" ]; then
export ETHEREUM_POLLING_INTERVAL=$ethereum_polling_interval
fi
case "${node_role-combined-node}" in
query-node)
start_query_node
;;
index-node)
start_index_node
;;
combined-node)
start_combined_node
;;
*)
echo "Unknown mode for start-node: $1"
echo "usage: start (combined-node|query-node|index-node)"
exit 1
esac

83
docker/wait_for Executable file
View File

@ -0,0 +1,83 @@
#!/bin/sh
# POSIX compatible clone of wait-for-it.sh
# This copy is from https://github.com/eficode/wait-for/commits/master
# at commit 8d9b4446
TIMEOUT=15
QUIET=0
echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}
usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$cmdname host:port [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}
wait_for() {
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1
result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
exec "$@"
fi
exit 0
fi
sleep 1
done
echo "Operation timed out" >&2
exit 1
}
while [ $# -gt 0 ]
do
case "$1" in
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-t)
TIMEOUT="$2"
if [ "$TIMEOUT" = "" ]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
break
;;
--help)
usage 0
;;
*)
echoerr "Unknown argument: $1"
usage 1
;;
esac
done
if [ "$HOST" = "" -o "$PORT" = "" ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi
wait_for "$@"

191
package-lock.json generated
View File

@ -83,9 +83,9 @@
} }
}, },
"@eslint/eslintrc": { "@eslint/eslintrc": {
"version": "0.2.2", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.2.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.3.0.tgz",
"integrity": "sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==", "integrity": "sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==",
"dev": true, "dev": true,
"requires": { "requires": {
"ajv": "^6.12.4", "ajv": "^6.12.4",
@ -95,7 +95,7 @@
"ignore": "^4.0.6", "ignore": "^4.0.6",
"import-fresh": "^3.2.1", "import-fresh": "^3.2.1",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"lodash": "^4.17.19", "lodash": "^4.17.20",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"strip-json-comments": "^3.1.1" "strip-json-comments": "^3.1.1"
}, },
@ -459,70 +459,71 @@
} }
}, },
"@typescript-eslint/eslint-plugin": { "@typescript-eslint/eslint-plugin": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.13.0.tgz",
"integrity": "sha512-QRLDSvIPeI1pz5tVuurD+cStNR4sle4avtHhxA+2uyixWGFjKzJ+EaFVRW6dA/jOgjV5DTAjOxboQkRDE8cRlQ==", "integrity": "sha512-ygqDUm+BUPvrr0jrXqoteMqmIaZ/bixYOc3A4BRwzEPTZPi6E+n44rzNZWaB0YvtukgP+aoj0i/fyx7FkM2p1w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/experimental-utils": "4.9.1", "@typescript-eslint/experimental-utils": "4.13.0",
"@typescript-eslint/scope-manager": "4.9.1", "@typescript-eslint/scope-manager": "4.13.0",
"debug": "^4.1.1", "debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1",
"lodash": "^4.17.15",
"regexpp": "^3.0.0", "regexpp": "^3.0.0",
"semver": "^7.3.2", "semver": "^7.3.2",
"tsutils": "^3.17.1" "tsutils": "^3.17.1"
} }
}, },
"@typescript-eslint/experimental-utils": { "@typescript-eslint/experimental-utils": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.13.0.tgz",
"integrity": "sha512-c3k/xJqk0exLFs+cWSJxIjqLYwdHCuLWhnpnikmPQD2+NGAx9KjLYlBDcSI81EArh9FDYSL6dslAUSwILeWOxg==", "integrity": "sha512-/ZsuWmqagOzNkx30VWYV3MNB/Re/CGv/7EzlqZo5RegBN8tMuPaBgNK6vPBCQA8tcYrbsrTdbx3ixMRRKEEGVw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/json-schema": "^7.0.3", "@types/json-schema": "^7.0.3",
"@typescript-eslint/scope-manager": "4.9.1", "@typescript-eslint/scope-manager": "4.13.0",
"@typescript-eslint/types": "4.9.1", "@typescript-eslint/types": "4.13.0",
"@typescript-eslint/typescript-estree": "4.9.1", "@typescript-eslint/typescript-estree": "4.13.0",
"eslint-scope": "^5.0.0", "eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0" "eslint-utils": "^2.0.0"
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.13.0.tgz",
"integrity": "sha512-Gv2VpqiomvQ2v4UL+dXlQcZ8zCX4eTkoIW+1aGVWT6yTO+6jbxsw7yQl2z2pPl/4B9qa5JXeIbhJpONKjXIy3g==", "integrity": "sha512-KO0J5SRF08pMXzq9+abyHnaGQgUJZ3Z3ax+pmqz9vl81JxmTTOUfQmq7/4awVfq09b6C4owNlOgOwp61pYRBSg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/scope-manager": "4.9.1", "@typescript-eslint/scope-manager": "4.13.0",
"@typescript-eslint/types": "4.9.1", "@typescript-eslint/types": "4.13.0",
"@typescript-eslint/typescript-estree": "4.9.1", "@typescript-eslint/typescript-estree": "4.13.0",
"debug": "^4.1.1" "debug": "^4.1.1"
} }
}, },
"@typescript-eslint/scope-manager": { "@typescript-eslint/scope-manager": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.13.0.tgz",
"integrity": "sha512-sa4L9yUfD/1sg9Kl8OxPxvpUcqxKXRjBeZxBuZSSV1v13hjfEJkn84n0An2hN8oLQ1PmEl2uA6FkI07idXeFgQ==", "integrity": "sha512-UpK7YLG2JlTp/9G4CHe7GxOwd93RBf3aHO5L+pfjIrhtBvZjHKbMhBXTIQNkbz7HZ9XOe++yKrXutYm5KmjWgQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/types": "4.9.1", "@typescript-eslint/types": "4.13.0",
"@typescript-eslint/visitor-keys": "4.9.1" "@typescript-eslint/visitor-keys": "4.13.0"
} }
}, },
"@typescript-eslint/types": { "@typescript-eslint/types": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.13.0.tgz",
"integrity": "sha512-fjkT+tXR13ks6Le7JiEdagnwEFc49IkOyys7ueWQ4O8k4quKPwPJudrwlVOJCUQhXo45PrfIvIarcrEjFTNwUA==", "integrity": "sha512-/+aPaq163oX+ObOG00M0t9tKkOgdv9lq0IQv/y4SqGkAXmhFmCfgsELV7kOCTb2vVU5VOmVwXBXJTDr353C1rQ==",
"dev": true "dev": true
}, },
"@typescript-eslint/typescript-estree": { "@typescript-eslint/typescript-estree": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.13.0.tgz",
"integrity": "sha512-bzP8vqwX6Vgmvs81bPtCkLtM/Skh36NE6unu6tsDeU/ZFoYthlTXbBmpIrvosgiDKlWTfb2ZpPELHH89aQjeQw==", "integrity": "sha512-9A0/DFZZLlGXn5XA349dWQFwPZxcyYyCFX5X88nWs2uachRDwGeyPz46oTsm9ZJE66EALvEns1lvBwa4d9QxMg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/types": "4.9.1", "@typescript-eslint/types": "4.13.0",
"@typescript-eslint/visitor-keys": "4.9.1", "@typescript-eslint/visitor-keys": "4.13.0",
"debug": "^4.1.1", "debug": "^4.1.1",
"globby": "^11.0.1", "globby": "^11.0.1",
"is-glob": "^4.0.1", "is-glob": "^4.0.1",
@ -532,12 +533,12 @@
} }
}, },
"@typescript-eslint/visitor-keys": { "@typescript-eslint/visitor-keys": {
"version": "4.9.1", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.9.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.13.0.tgz",
"integrity": "sha512-9gspzc6UqLQHd7lXQS7oWs+hrYggspv/rk6zzEMhCbYwPE/sF7oxo7GAjkS35Tdlt7wguIG+ViWCPtVZHz/ybQ==", "integrity": "sha512-6RoxWK05PAibukE7jElqAtNMq+RWZyqJ6Q/GdIxaiUj2Ept8jh8+FUVlbq9WxMYxkmEOPvCE5cRSyupMpwW31g==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/types": "4.9.1", "@typescript-eslint/types": "4.13.0",
"eslint-visitor-keys": "^2.0.0" "eslint-visitor-keys": "^2.0.0"
} }
}, },
@ -1884,13 +1885,13 @@
"dev": true "dev": true
}, },
"eslint": { "eslint": {
"version": "7.15.0", "version": "7.18.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.15.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.18.0.tgz",
"integrity": "sha512-Vr64xFDT8w30wFll643e7cGrIkPEU50yIiI36OdSIDoSGguIeaLzBo0vpGvzo9RECUqq7htURfwEtKqwytkqzA==", "integrity": "sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
"@eslint/eslintrc": "^0.2.2", "@eslint/eslintrc": "^0.3.0",
"ajv": "^6.10.0", "ajv": "^6.10.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
"cross-spawn": "^7.0.2", "cross-spawn": "^7.0.2",
@ -1914,7 +1915,7 @@
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1", "json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1", "levn": "^0.4.1",
"lodash": "^4.17.19", "lodash": "^4.17.20",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
"optionator": "^0.9.1", "optionator": "^0.9.1",
@ -1923,7 +1924,7 @@
"semver": "^7.2.1", "semver": "^7.2.1",
"strip-ansi": "^6.0.0", "strip-ansi": "^6.0.0",
"strip-json-comments": "^3.1.0", "strip-json-comments": "^3.1.0",
"table": "^5.2.3", "table": "^6.0.4",
"text-table": "^0.2.0", "text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3" "v8-compile-cache": "^2.0.3"
}, },
@ -1940,6 +1941,12 @@
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true "dev": true
}, },
"astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
"dev": true
},
"chalk": { "chalk": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
@ -1950,6 +1957,12 @@
"supports-color": "^7.1.0" "supports-color": "^7.1.0"
} }
}, },
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
},
"enquirer": { "enquirer": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
@ -1959,6 +1972,40 @@
"ansi-colors": "^4.1.1" "ansi-colors": "^4.1.1"
} }
}, },
"is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true
},
"json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true
},
"slice-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz",
"integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==",
"dev": true,
"requires": {
"ansi-styles": "^4.0.0",
"astral-regex": "^2.0.0",
"is-fullwidth-code-point": "^3.0.0"
}
},
"string-width": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
"integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
"dev": true,
"requires": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.0"
}
},
"strip-ansi": { "strip-ansi": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
@ -1973,6 +2020,32 @@
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true "dev": true
},
"table": {
"version": "6.0.7",
"resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz",
"integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==",
"dev": true,
"requires": {
"ajv": "^7.0.2",
"lodash": "^4.17.20",
"slice-ansi": "^4.0.0",
"string-width": "^4.2.0"
},
"dependencies": {
"ajv": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz",
"integrity": "sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.2.2"
}
}
}
} }
} }
}, },
@ -2275,9 +2348,9 @@
} }
}, },
"eslint-config-prettier": { "eslint-config-prettier": {
"version": "7.0.0", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.1.0.tgz",
"integrity": "sha512-8Y8lGLVPPZdaNA7JXqnvETVC7IiVRgAP6afQu9gOQRn90YY3otMNh+x7Vr2vMePQntF+5erdSUBqSzCmU/AxaQ==", "integrity": "sha512-9sm5/PxaFG7qNJvJzTROMM1Bk1ozXVTKI0buKOyb0Bsr1hrwi0H/TzxF/COtf1uxikIK8SwhX7K6zg78jAzbeA==",
"dev": true "dev": true
}, },
"eslint-config-standard": { "eslint-config-standard": {
@ -2480,9 +2553,9 @@
} }
}, },
"eslint-plugin-prettier": { "eslint-plugin-prettier": {
"version": "3.2.0", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.2.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
"integrity": "sha512-kOUSJnFjAUFKwVxuzy6sA5yyMx6+o9ino4gCdShzBNx4eyFRudWRYKCFolKjoM40PEiuU6Cn7wBLfq3WsGg7qg==", "integrity": "sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"prettier-linter-helpers": "^1.0.0" "prettier-linter-helpers": "^1.0.0"
@ -6589,6 +6662,12 @@
} }
} }
}, },
"require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
"dev": true
},
"resolve": { "resolve": {
"version": "1.19.0", "version": "1.19.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
@ -7275,9 +7354,9 @@
"dev": true "dev": true
}, },
"tsutils": { "tsutils": {
"version": "3.17.1", "version": "3.19.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.19.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", "integrity": "sha512-GEdoBf5XI324lu7ycad7s6laADfnAqCw6wLGI+knxvw9vsIYBaJfYdmeCEG3FMMUiSm3OGgNb+m6utsWf5h9Vw==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.8.1" "tslib": "^1.8.1"
@ -7329,9 +7408,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "4.1.2", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.2.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
"integrity": "sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==", "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {

View File

@ -7,14 +7,14 @@
"create:local": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020", "create:local": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"create:local-rinkeby": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020", "create:local-rinkeby": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"create:local-ropsten": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020", "create:local-ropsten": "graph create oceanprotocol/ocean-subgraph --node http://127.0.0.1:8020",
"codegen": "graph codegen --output-dir src/types/", "codegen": "graph codegen --output-dir src/@types",
"build": "graph build", "build": "graph build",
"deploy": "graph deploy oceanprotocol/ocean-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", "deploy": "graph deploy oceanprotocol/ocean-subgraph --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:beta": "graph deploy oceanprotocol/ocean-subgraph-beta --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/", "deploy:beta": "graph deploy oceanprotocol/ocean-subgraph-beta --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020", "deploy:local": "graph deploy oceanprotocol/ocean-subgraph subgraph.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"deploy:local-rinkeby": "graph deploy oceanprotocol/ocean-subgraph subgraph.rinkeby.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020", "deploy:local-rinkeby": "graph deploy oceanprotocol/ocean-subgraph subgraph.rinkeby.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"deploy:local-ropsten": "graph deploy oceanprotocol/ocean-subgraph subgraph.ropsten.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020", "deploy:local-ropsten": "graph deploy oceanprotocol/ocean-subgraph subgraph.ropsten.yaml --debug --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020",
"test": "npm run lint && npm run type-check", "test": "npm run codegen && npm run lint && npm run type-check",
"lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .", "lint": "eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx .",
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write", "format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json,yaml}' --write",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
@ -25,16 +25,16 @@
"@graphprotocol/graph-cli": "^0.19.0", "@graphprotocol/graph-cli": "^0.19.0",
"@graphprotocol/graph-ts": "^0.19.0", "@graphprotocol/graph-ts": "^0.19.0",
"@release-it/bumper": "^2.0.0", "@release-it/bumper": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^4.9.1", "@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.9.1", "@typescript-eslint/parser": "^4.13.0",
"auto-changelog": "^2.2.1", "auto-changelog": "^2.2.1",
"eslint": "^7.15.0", "eslint": "^7.18.0",
"eslint-config-oceanprotocol": "^1.5.0", "eslint-config-oceanprotocol": "^1.5.0",
"eslint-config-prettier": "^7.0.0", "eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.2.0", "eslint-plugin-prettier": "^3.3.1",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"release-it": "^14.2.2", "release-it": "^14.2.2",
"typescript": "^4.1.2" "typescript": "^4.1.3"
}, },
"dependencies": {}, "dependencies": {},
"repository": { "repository": {

View File

@ -1,8 +1,9 @@
type PoolFactory @entity { type PoolFactory @entity {
id: ID! id: ID!
totalLockedValue: BigDecimal # total value from all pools expressed in OCEAN totalValueLocked: BigDecimal # total value from all pools expressed in OCEAN
totalLiquidity: BigDecimal! # All the pools liquidity value in Ocean
totalOceanLiquidity: BigDecimal! # Total of OCEAN liquidity from all pools
totalSwapVolume: BigDecimal! # All the swap volume in Ocean totalSwapVolume: BigDecimal! # All the swap volume in Ocean
totalSwapFee: BigDecimal! # All the swap fee in Ocean totalSwapFee: BigDecimal! # All the swap fee in Ocean
@ -29,7 +30,7 @@ type Pool @entity {
totalSwapVolume: BigDecimal! # Total swap volume in OCEAN totalSwapVolume: BigDecimal! # Total swap volume in OCEAN
totalSwapFee: BigDecimal! # Total swap fee in OCEAN totalSwapFee: BigDecimal! # Total swap fee in OCEAN
lockedValue: BigDecimal! # locked value expressed in OCEAN (captures both Ocean and Datatoken) valueLocked: BigDecimal! # value locked in pool expressed in OCEAN (captures both Ocean and Datatoken)
datatokenReserve: BigDecimal! # Total pool reserve of Datatoken datatokenReserve: BigDecimal! # Total pool reserve of Datatoken
oceanReserve: BigDecimal! # Total pool reserve of OCEAN oceanReserve: BigDecimal! # Total pool reserve of OCEAN
spotPrice: BigDecimal! spotPrice: BigDecimal!

View File

@ -19,9 +19,9 @@ import {
TokenBalance, TokenBalance,
TokenTransaction, TokenTransaction,
PoolTransactionTokenValues PoolTransactionTokenValues
} from './types/schema' } from './@types/schema'
import { Pool } from './types/templates/Pool/Pool' import { Pool } from './@types/templates/Pool/Pool'
export const ZERO_BD = BigDecimal.fromString('0.0') export const ZERO_BD = BigDecimal.fromString('0.0')
export const MINUS_1_BD = BigDecimal.fromString('-1.0') export const MINUS_1_BD = BigDecimal.fromString('-1.0')
@ -34,8 +34,6 @@ export const ENABLE_DEBUG = true
const network = dataSource.network() const network = dataSource.network()
export const OCEAN: string = getOceanAddress()
function getOceanAddress(): string { function getOceanAddress(): string {
if (network == 'ropsten') { if (network == 'ropsten') {
return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9' return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
@ -46,6 +44,8 @@ function getOceanAddress(): string {
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48' return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
} }
export const OCEAN: string = getOceanAddress()
export function _debuglog( export function _debuglog(
message: string, message: string,
event: ethereum.Event, event: ethereum.Event,
@ -109,6 +109,12 @@ export function updatePoolTokenBalance(
null, null,
[source, poolToken.balance.toString(), balance.toString(), poolToken.poolId] [source, poolToken.balance.toString(), balance.toString(), poolToken.poolId]
) )
if (balance < ZERO_BD || poolToken.balance < ZERO_BD) {
log.warning(
'EEEEEEEEEEEEEEEEE poolToken.balance < Zero: pool={}, poolToken={}, oldBalance={}, newBalance={}',
[poolToken.poolId, poolToken.tokenAddress.toString(), poolToken.balance.toString(), balance.toString()])
}
poolToken.balance = balance poolToken.balance = balance
} }
@ -183,8 +189,16 @@ export function updatePoolTransactionToken(
ptxTokenValues.save() ptxTokenValues.save()
if (ptxTokenValues.tokenAddress == OCEAN) { if (ptxTokenValues.tokenAddress == OCEAN) {
const factory = PoolFactory.load('1')
factory.totalOceanLiquidity = factory.totalOceanLiquidity + ptxTokenValues.tokenReserve - pool.oceanReserve
if (factory.totalOceanLiquidity < ZERO_BD || pool.oceanReserve < ZERO_BD) {
log.warning(
'EEEEEEEEEEEEEEEEE totalOceanLiquidity or oceanReserve < Zero: pool={}, totOcnLiq={}, ocnRes={}',
[pool.id, factory.totalOceanLiquidity.toString(), pool.oceanReserve.toString()])
}
ptx.oceanReserve = ptxTokenValues.tokenReserve ptx.oceanReserve = ptxTokenValues.tokenReserve
pool.oceanReserve = ptxTokenValues.tokenReserve pool.oceanReserve = ptxTokenValues.tokenReserve
factory.save()
} else { } else {
ptx.datatokenReserve = ptxTokenValues.tokenReserve ptx.datatokenReserve = ptxTokenValues.tokenReserve
pool.datatokenReserve = ptxTokenValues.tokenReserve pool.datatokenReserve = ptxTokenValues.tokenReserve
@ -310,10 +324,18 @@ export function createPoolTransaction(
pool.consumePrice = poolTx.consumePrice pool.consumePrice = poolTx.consumePrice
pool.spotPrice = poolTx.spotPrice pool.spotPrice = poolTx.spotPrice
const lockedValue = pool.lockedValue const oldValueLocked = pool.valueLocked
pool.lockedValue = pool.oceanReserve + (pool.datatokenReserve * pool.spotPrice) const spotPrice = pool.spotPrice >= ZERO_BD ? pool.spotPrice : ZERO_BD
let factory = PoolFactory.load('1') pool.valueLocked = poolTx.oceanReserve + (poolTx.datatokenReserve * spotPrice)
factory.totalLockedValue = factory.totalLockedValue - lockedValue + pool.lockedValue const factory = PoolFactory.load('1')
if (oldValueLocked < ZERO_BD || pool.valueLocked < ZERO_BD) {
log.warning(
'EEEEEEEEEEEEEEEEE valueLocked < Zero: pool={}, oldVL={}, newVL={}, OCEAN={}, DT={}, spotPrice={}',
[pool.id, oldValueLocked.toString(), pool.valueLocked.toString(),
poolTx.oceanReserve.toString(), poolTx.datatokenReserve.toString(),
pool.spotPrice.toString()])
}
factory.totalValueLocked = factory.totalValueLocked - oldValueLocked + pool.valueLocked
pool.transactionCount = pool.transactionCount.plus(BigInt.fromI32(1)) pool.transactionCount = pool.transactionCount.plus(BigInt.fromI32(1))

View File

@ -1,7 +1,7 @@
import { BigInt, BigDecimal } from '@graphprotocol/graph-ts' import { BigInt, BigDecimal } from '@graphprotocol/graph-ts'
import { OrderStarted, Transfer } from '../types/templates/DataToken/DataToken' import { OrderStarted, Transfer } from '../@types/templates/DataToken/DataToken'
import { Datatoken, TokenBalance, TokenOrder } from '../types/schema' import { Datatoken, TokenBalance, TokenOrder } from '../@types/schema'
import { import {
tokenToDecimal, tokenToDecimal,
updateTokenBalance, updateTokenBalance,

View File

@ -1,7 +1,10 @@
import { BigInt, log } from '@graphprotocol/graph-ts' import { BigInt, log } from '@graphprotocol/graph-ts'
import { TokenRegistered } from '../types/DTFactory/DTFactory' import { TokenRegistered } from '../@types/DTFactory/DTFactory'
import { DatatokenFactory, Datatoken as DatatokenEntity } from '../types/schema' import {
import { DataToken as DatatokenDataSource } from '../types/templates' DatatokenFactory,
Datatoken as DatatokenEntity
} from '../@types/schema'
import { DataToken as DatatokenDataSource } from '../@types/templates'
import { createUserEntity, tokenToDecimal, ZERO_BD } from '../helpers' import { createUserEntity, tokenToDecimal, ZERO_BD } from '../helpers'

View File

@ -1,7 +1,7 @@
import { BigInt, BigDecimal, log } from '@graphprotocol/graph-ts' import { BigInt, BigDecimal, log } from '@graphprotocol/graph-ts'
import { BPoolRegistered } from '../types/Factory/Factory' import { BPoolRegistered } from '../@types/Factory/Factory'
import { PoolFactory, Pool } from '../types/schema' import { PoolFactory, Pool } from '../@types/schema'
import { Pool as PoolContract } from '../types/templates' import { Pool as PoolContract } from '../@types/templates'
import { ZERO_BD } from '../helpers' import { ZERO_BD } from '../helpers'
export function handleNewPool(event: BPoolRegistered): void { export function handleNewPool(event: BPoolRegistered): void {
@ -9,10 +9,10 @@ export function handleNewPool(event: BPoolRegistered): void {
if (factory == null) { if (factory == null) {
factory = new PoolFactory('1') factory = new PoolFactory('1')
factory.totalLiquidity = ZERO_BD factory.totalOceanLiquidity = ZERO_BD
factory.totalSwapVolume = ZERO_BD factory.totalSwapVolume = ZERO_BD
factory.totalSwapFee = ZERO_BD factory.totalSwapFee = ZERO_BD
factory.totalLockedValue = ZERO_BD factory.totalValueLocked = ZERO_BD
factory.poolCount = 0 factory.poolCount = 0
factory.finalizedPoolCount = 0 factory.finalizedPoolCount = 0
@ -37,7 +37,7 @@ export function handleNewPool(event: BPoolRegistered): void {
pool.totalShares = ZERO_BD pool.totalShares = ZERO_BD
pool.totalSwapVolume = ZERO_BD pool.totalSwapVolume = ZERO_BD
pool.totalSwapFee = ZERO_BD pool.totalSwapFee = ZERO_BD
pool.lockedValue = ZERO_BD pool.valueLocked = ZERO_BD
pool.datatokenReserve = ZERO_BD pool.datatokenReserve = ZERO_BD
pool.oceanReserve = ZERO_BD pool.oceanReserve = ZERO_BD

View File

@ -5,7 +5,7 @@ import {
LOG_EXIT, LOG_EXIT,
LOG_SWAP, LOG_SWAP,
Transfer Transfer
} from '../types/templates/Pool/Pool' } from '../@types/templates/Pool/Pool'
import { import {
PoolFactory, PoolFactory,
@ -14,7 +14,7 @@ import {
PoolShare, PoolShare,
Datatoken, Datatoken,
PoolTransaction PoolTransaction
} from '../types/schema' } from '../@types/schema'
import { import {
hexToDecimal, hexToDecimal,
tokenToDecimal, tokenToDecimal,
@ -425,6 +425,8 @@ export function handleTransfer(event: Transfer): void {
const pool = Pool.load(poolId) const pool = Pool.load(poolId)
const poolTx = PoolTransaction.load(event.transaction.hash.toHexString()) const poolTx = PoolTransaction.load(event.transaction.hash.toHexString())
const value = tokenToDecimal(event.params.value.toBigDecimal(), 18) const value = tokenToDecimal(event.params.value.toBigDecimal(), 18)
debuglog('poolShare Transfer event: (from, to, value)', event,
[event.params.from.toHex(), event.params.to.toHex(), value.toString()])
if (isMint) { if (isMint) {
if (poolShareTo == null) { if (poolShareTo == null) {
@ -438,8 +440,17 @@ export function handleTransfer(event: Transfer): void {
poolTx.sharesTransferAmount = value poolTx.sharesTransferAmount = value
poolTx.sharesBalance = poolShareTo.balance poolTx.sharesBalance = poolShareTo.balance
} }
debuglog('pool shares mint: (id, value, totalShares)', event, [poolId, value.toString(), pool.totalShares.toString()]) debuglog(
'pool shares mint: (id, value, totalShares, shareToBalance, toAddress)',
event,
[
poolId,
value.toString(),
pool.totalShares.toString(),
poolShareTo.balance.toString(),
poolShareTo.userAddress
]
)
} else if (isBurn) { } else if (isBurn) {
if (poolShareFrom == null) { if (poolShareFrom == null) {
createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex()) createPoolShareEntity(poolShareFromId, poolId, event.params.from.toHex())
@ -452,7 +463,17 @@ export function handleTransfer(event: Transfer): void {
poolTx.sharesTransferAmount = -value poolTx.sharesTransferAmount = -value
poolTx.sharesBalance = poolShareFrom.balance poolTx.sharesBalance = poolShareFrom.balance
} }
debuglog('pool shares burn: (id, value, totalShares)', event, [poolId, value.toString(), pool.totalShares.toString()]) debuglog(
'pool shares burn: (id, value, totalShares, shareFromBalance, fromAddress)',
event,
[
poolId,
value.toString(),
pool.totalShares.toString(),
poolShareFrom.balance.toString(),
poolShareFrom.userAddress
]
)
} else { } else {
if (poolShareTo == null) { if (poolShareTo == null) {
createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex()) createPoolShareEntity(poolShareToId, poolId, event.params.to.toHex())
@ -467,6 +488,13 @@ export function handleTransfer(event: Transfer): void {
} }
poolShareFrom.balance -= value poolShareFrom.balance -= value
poolShareFrom.save() poolShareFrom.save()
debuglog(
'pool shares transfer: ' +
'(id, value, totalShares, shareToBalance, shareFromBalance, toAddress, fromAddress)', event,
[poolId, value.toString(), pool.totalShares.toString(),
poolShareTo.balance.toString(), poolShareFrom.balance.toString(),
poolShareTo.userAddress, poolShareFrom.userAddress
])
} }
if ( if (