Skip to content

Commit

Permalink
Merge pull request #17 from rsksmart/pegin-status-integration
Browse files Browse the repository at this point in the history
Pegin status integration
  • Loading branch information
josedahlquist authored Jul 28, 2021
2 parents 679b422 + 9446d12 commit d31647d
Show file tree
Hide file tree
Showing 52 changed files with 2,030 additions and 51 deletions.
8 changes: 8 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ RSK_NODE_HOST='https://public-node.testnet.rsk.co'
LOCAL_TEST=1
TEST_FEDERATION_ADDRESS='2ND7Zf42GPg1JJb5TQGYXkM4Ygz74spV8MR'
TTL_SESSIONDB_EXPIRE_MILLISECONDS=172800000
METRICS_ENABLED=false;

# MONGODB CONNECTION
RSK_DB_USER='api-user'
RSK_DB_PASS='pwd'
RSK_DB_URL='localhost'
RSK_DB_PORT=27017
RSK_DB_NAME=rsk
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Logs
logs
*.log
*.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down Expand Up @@ -70,3 +70,6 @@ data/*
SessionDB/data/redis-data
sonar-project.properties
.scannerwork

# rsk db data
rsk-database/db
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"eslint.validate": [
"javascript",
"typescript"
]
],
"js/ts.implicitProjectConfig.experimentalDecorators": true
}
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,34 @@ npm ci
Move to the `SessionDB` folder and run:

```sh
docker-compose up
docker-compose up -d
```

### RSK DB
Move to the `rsk-database` folder, copy your `.env` file in it and then run:
```sh
docker-compose up -d
```

For some reason passing `--env-file` argument to docker-compose doesn't seem to be working fine. That's why we need to copy the `.env` file here too.

## Run the application
If you want to start the API alongside the daemon run:
```sh
npm start
```

If you prefer to execute just the API run:
```sh
npm run start-api
```

Open http://127.0.0.1:3000 in your browser to discover the API capabilities

Open http://127.0.0.1:3000 in your browser.
If you prefer to execute just the daemon run:
```sh
npm run start-daemon
```


## Fix code style and formatting issues
Expand Down
157 changes: 151 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"rebuild": "npm run clean && npm run build",
"prestart": "npm run rebuild",
"start": "node -r source-map-support/register .",
"start-daemon": "npm run prestart && node -r source-map-support/register . --appmode=DAEMON",
"start-api": "npm run prestart && node -r source-map-support/register . --appmode=API",
"clean": "lb-clean dist *.tsbuildinfo .eslintcache"
},
"repository": {
Expand All @@ -57,12 +59,15 @@
"@loopback/rest-explorer": "^3.0.5",
"@loopback/service-proxy": "^3.0.5",
"@rsksmart/rsk-precompiled-abis": "^3.0.0-PAPYRUS",
"dotenv": "^8.2.0",
"@types/mongoose": "^5.11.97",
"dotenv": "^8.6.0",
"js-sha256": "^0.9.0",
"log4js": "^6.3.0",
"loopback-connector-kv-redis": "^3.0.3",
"loopback-connector-mongodb": "^5.5.0",
"loopback-connector-redis": "^3.0.0",
"loopback-connector-rest": "^3.7.0",
"mongoose": "^5.13.2",
"pegin-address-verificator": "github:rsksmart/pegin-address-verifier#master",
"pegin-cap-evaluator": "github:rsksmart/pegin-cap-evaluator#master",
"tslib": "^2.0.0",
Expand All @@ -74,6 +79,7 @@
"@loopback/build": "^6.2.8",
"@loopback/eslint-config": "^10.0.4",
"@loopback/testlab": "^3.2.10",
"@types/bs58": "^4.0.1",
"@types/node": "^10.17.48",
"eslint": "^7.15.0",
"sonarqube-scanner": "^2.8.0",
Expand Down
20 changes: 20 additions & 0 deletions rsk-database/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.1'

services:

mongo:
image: mongo
container_name: '2wp-rsk-mongo-database'
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${RSK_DB_ROOT_USER}
MONGO_INITDB_ROOT_PASSWORD: ${RSK_DB_ROOT_PASS}
MONGO_INITDB_DATABASE: ${RSK_DB_NAME}
MONGO_INITDB_USER: ${RSK_DB_USER}
MONGO_INITDB_PWD: ${RSK_DB_PASS}
volumes:
- ./mongo-init.sh/:/docker-entrypoint-initdb.d/mongo-init.sh:ro
# - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
- ./db:/data/db
ports:
- '27017-27019:27017-27019'
18 changes: 18 additions & 0 deletions rsk-database/mongo-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set -e
DB=rsk # $MONGO_INITDB_DATABASE
USER=api-user # $MONGO_INITDB_USER
PASS=pwd # $MONGO_INITDB_PASS
# TODO: for some reason the sh file is not using the env variables set in the yml file so I'm hardcoding them

mongo <<EOF
use $DB
db.createUser({
user: '$USER',
pwd: '$PASS',
roles: [{
role: 'readWrite',
db: '$DB'
}]
})
EOF
Loading

0 comments on commit d31647d

Please sign in to comment.