Skip to content

Commit

Permalink
Merge pull request #191 from humanprotocol/feature/fortune-JL-server
Browse files Browse the repository at this point in the history
Fortune Job Launcher Server
  • Loading branch information
portuu3 authored Jan 26, 2023
2 parents 9c82fab + 473c2a3 commit 40c1385
Show file tree
Hide file tree
Showing 28 changed files with 2,026 additions and 30 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci-test-fortune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ jobs:
node-version: 18
- run: npm install --global yarn && yarn --ignore-scripts
name: npm Install dependencies
- run: yarn && yarn install:all
working-directory: ./packages/examples/fortune
name: npm Install Fortune dependencies
- run: yarn fortune:test
name: Run fortune test
2 changes: 1 addition & 1 deletion packages/core/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
networks: {
localhost: {
url: 'http://127.0.0.1:8545',
url: `http://127.0.0.1:${process.env.RPC_PORT || '8545'}`,
},
hardhat: {
forking: process.env.FORKING_URL
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@human-protocol/core",
"description": "Human Protocol Core Smart Contracts",
"version": "1.0.37",
"version": "1.0.39",
"files": [
"contracts/**/*.sol",
"abis/**/*.json",
Expand Down
19 changes: 19 additions & 0 deletions packages/examples/fortune/launcher/server/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NODE_ENV='development'
LOG_LEVEL='debug'
API_HOST='localhost'
API_PORT='8080'
S3_HOST=localhost
S3_PORT=80
S3_ACCESS_KEY=access-key
S3_SECRET_KEY=secret-key
S3_BUCKET_NAME=fortune-manifests
S3_BASE_URL=http://localhost
ETH_PRIVATE_KEY=df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e
REC_ORACLE_ADDRESS=0x670bCc966ddc4fE7136c8793617a2C4D22849827
REP_ORACLE_ADDRESS=0x6aC0881d52B08a9FF766b9Ac51FD9F488D761d98
EX_ORACLE_ADDRESS=0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec
REC_ORACLE_URL=http://localhost
REP_ORACLE_URL=http://localhost
EX_ORACLE_URL=http://localhost
REC_ORACLE_PERCENTAGE_FEE=10
REP_ORACLE_PERCENTAGE_FEE=10
35 changes: 35 additions & 0 deletions packages/examples/fortune/launcher/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Job Launcher server
Job Launcher server is an API that allows Human Protocol users to create jobs.
### Validations:
1. In order to accept the job creation the user needs to approve to the job launcher address, in the contract of the token selected, to spend the amount of tokens desired for funding the escrow.
2. Check for curse words in title and description.

### Flow:
1. User approves the amount necessary
2. User submits the escrow data calling ```POST /escrow```
3. Server passes validations
4. Server creates the escrow
5. Server funds the escrow
6. Server uploads manifest with the escrow data
7. Server sets the escrow up
8. Server returns escrow address


## Run locally
1. Create a copy of .env.test and call it .env:

```bash
cp .env.test .env
````

2. Edit .env file with the required values.
3. Start the server:

```bash
yarn start
```

## Tests
```bash
yarn test
```
27 changes: 27 additions & 0 deletions packages/examples/fortune/launcher/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@human-protocol/job-launcher-server",
"version": "1.0.0",
"description": "Job Launcher Server",
"main": "index.ts",
"license": "MIT",
"private": false,
"type": "module",
"dependencies": {
"@fastify/cors": "^8.2.0",
"@human-protocol/core": "workspace:*",
"@types/node": "^18.11.18",
"bn.js": "^5.2.1",
"fastify": "^4.11.0",
"typescript": "^4.9.4"
},
"devDependencies": {
"pino-pretty": "^9.1.1",
"ts-node": "^10.9.1",
"vitest": "^0.28.1"
},
"scripts": {
"build": "tsc",
"start": "ts-node --esm ./src/index.ts",
"test": "concurrently -k -s first --hide 0 \"hardhat node --port 8546\" \"sleep 5 && cross-env RPC_PORT=8546 yarn workspace @human-protocol/core deploy:local && vitest --run\""
}
}
Loading

0 comments on commit 40c1385

Please sign in to comment.