Skip to content

Commit

Permalink
feat: add fortune exchange oracle to e2e environment (#1706)
Browse files Browse the repository at this point in the history
* feat: add fortune exchange oracle to e2e environment

* improvements on dev script

---------

Co-authored-by: portuu3 <[email protected]>
  • Loading branch information
leric7 and portuu3 authored Mar 14, 2024
1 parent adc0ac3 commit 650316f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
9 changes: 4 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"dist/typechain-types"
],
"scripts": {
"clean": "hardhat clean && rm -rf abis cache artifacts typechain-types",
"precompile": "npm run clean",
"clean": "hardhat clean && rm -rf abis cache artifacts typechain-types dist",
"compile": "hardhat compile",
"verify": "hardhat verify",
"test": "hardhat test",
Expand All @@ -33,9 +32,9 @@
"format:contracts": "prettier --write '**/*.sol'",
"format:scripts": "prettier --write '**/*.ts'",
"format": "yarn format:contracts && yarn format:scripts",
"build": "npm run compile && tsc",
"prebuild": "rm -rf dist",
"prepublish": "npm run build"
"build": "yarn compile && tsc",
"prebuild": "yarn clean",
"prepublish": "yarn build"
},
"repository": {
"type": "git",
Expand Down
22 changes: 15 additions & 7 deletions scripts/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: check-file fortune

check-legacy-abis:
@if [ ! -d "../packages/core/abis/legacy" ]; then \
yarn workspace @human-protocol/core build; \
check-core-folders:
@if [ ! -d "../packages/core/abis/legacy" ] || [ ! -d "../packages/core/typechain-types" ]; then \
yarn workspace @human-protocol/sdk build; \
fi

create-env-files:
Expand All @@ -14,15 +14,21 @@ create-env-files:
cp ./fortune/.env.jl-client ../packages/apps/job-launcher/client/.env.local ; \
fi

@if [ ! -f "../packages/apps/fortune/exchange-oracle/server/.env.local" ]; then \
cp ./fortune/.env.exco-server ../packages/apps/fortune/exchange-oracle/server/.env.local ; \
fi

hardhat-node:
yarn workspace @human-protocol/core local

subgraph:
sleep 5
$(MAKE) check-legacy-abis
docker compose -f ./fortune/docker-compose.yml up -d graph-node
NETWORK=localhost yarn workspace @human-protocol/subgraph generate
sleep 10
check-container-health:
@while [ $$(docker inspect --format='{{.State.Health.Status}}' graph-node) != "healthy" ]; do \
sleep 2; \
done; \
echo "Container is healthy."
yarn workspace @human-protocol/subgraph create-local
yarn workspace @human-protocol/subgraph deploy-local

Expand All @@ -42,14 +48,16 @@ job-launcher-client:

fortune-exchange-oracle:
yarn workspace @human-protocol/fortune-exchange-oracle-server setup:local
NODE_ENV=local yarn workspace @human-protocol/fortune-exchange-oracle-server migration:run
NODE_ENV=local yarn workspace @human-protocol/fortune-exchange-oracle-server start

fortune-recording-oracle:
yarn workspace @human-protocol/fortune-recording-oracle setup:local

reputation-oracle:
yarn workspace @human-protocol/reputation-oracle setup:local

fortune:
fortune: check-core-folders
@echo "RUNNING FORTUNE..."
@trap 'echo "STOPPING FORTUNE.."; kill -9 $$PID_HARDHAT $$PID_JL_CLIENT $$PID_JL_SERVER $$PID_EXO $$PID_RECO; docker compose -f ./fortune/docker-compose.yml down; exit 0' SIGINT ERR; \
$(MAKE) hardhat-node & PID_HARDHAT=$$!; \
Expand Down
25 changes: 25 additions & 0 deletions scripts/fortune/.env.exco-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# General
NODE_ENV=development
PORT=5003

# Database
POSTGRES_HOST=0.0.0.0
POSTGRES_USER=default
POSTGRES_PASSWORD=qwerty
POSTGRES_DATABASE=exchange-oracle
POSTGRES_SYNC=false
POSTGRES_PORT=5432
POSTGRES_SSL=false
POSTGRES_LOGGING='all'

# S3
S3_ENDPOINT=localhost
S3_PORT=9000
S3_ACCESS_KEY=access-key
S3_SECRET_KEY=secret-key

WEB3_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a #0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC

PGP_ENCRYPT=false
# PGP_PRIVATE_KEY=
# PGP_PASSPHRASE=
5 changes: 4 additions & 1 deletion scripts/fortune/.env.jl-server
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ STRIPE_APP_VERSION=1.0.0
STRIPE_APP_INFO_URL=https://github.com/humanprotocol/human-protocol/tree/main/packages/apps/job-launcher/server

#Sendgrid
SENDGRID_API_KEY=
SENDGRID_API_KEY=

#Cron jobs secret
CRON_SECRET=secret
1 change: 1 addition & 0 deletions scripts/fortune/initdb/create-dbs.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CREATE DATABASE "job-launcher";
CREATE DATABASE "graph-node";
CREATE DATABASE "exchange-oracle";
CREATE DATABASE "reputation-oracle";

0 comments on commit 650316f

Please sign in to comment.