Browse Source

Merge branch 'restore-docker-configuration' into 'implement-ui'

Restore docker configuration

See merge request ecentrics/apella!3
develop
Apostolos Fanakis 4 years ago
parent
commit
2f7494a442
  1. 22
      .dockerignore
  2. 4
      .gitignore
  3. 37
      README.md
  4. 67
      docker/Makefile
  5. 204
      docker/README.md
  6. 72
      docker/concordia-app/Dockerfile
  7. 22
      docker/concordia-app/nginx.conf
  8. 11
      docker/concordia-app/test-app.sh
  9. 66
      docker/concordia-contracts/Dockerfile
  10. 6
      docker/concordia-contracts/migrate.sh
  11. 16
      docker/concordia-contracts/test-contracts.sh
  12. 34
      docker/docker-compose.yml
  13. 7
      docker/env/concordia.docker.env
  14. 20
      docker/env/concordia.example.env
  15. 14
      docker/env/contracts.docker.env
  16. 7
      docker/env/contracts.example.env
  17. 5
      docker/env/ganache.docker.env
  18. 6
      docker/env/ganache.test.docker.env
  19. 10
      docker/ganache/Dockerfile
  20. 37
      docker/ganache/start-blockchain.sh
  21. 11
      package.json
  22. 0
      packages/concordia-app/.dockerignore
  23. 12
      packages/concordia-app/.env.development.example
  24. 18
      packages/concordia-app/.gitignore
  25. 4
      packages/concordia-app/public/manifest.json
  26. 2
      packages/concordia-app/src/components/InitializationScreen/index.jsx
  27. 10
      packages/concordia-app/src/components/PostCreate/index.jsx
  28. 8
      packages/concordia-app/src/components/PostList/PostListRow/index.jsx
  29. 2
      packages/concordia-app/src/components/PostList/index.jsx
  30. 8
      packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx
  31. 2
      packages/concordia-app/src/components/TopicList/index.jsx
  32. 2
      packages/concordia-app/src/constants/PlaceholderTypes.js
  33. 7
      packages/concordia-app/src/constants/configuration/defaults.js
  34. 0
      packages/concordia-app/src/constants/contracts/ContractNames.js
  35. 0
      packages/concordia-app/src/constants/contracts/events/ForumContractEvents.js
  36. 8
      packages/concordia-app/src/constants/contracts/events/index.js
  37. 0
      packages/concordia-app/src/constants/orbit/OrbitDatabases.js
  38. 0
      packages/concordia-app/src/constants/orbit/PostsDatabaseKeys.js
  39. 0
      packages/concordia-app/src/constants/orbit/TopicsDatabaseKeys.js
  40. 0
      packages/concordia-app/src/constants/orbit/UserDatabaseKeys.js
  41. 11
      packages/concordia-app/src/options/breezeOptions.js
  42. 13
      packages/concordia-app/src/options/drizzleOptions.js
  43. 27
      packages/concordia-app/src/options/web3Options.js
  44. 2
      packages/concordia-app/src/redux/actions/contractEventActions.js
  45. 8
      packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js
  46. 2
      packages/concordia-app/src/redux/sagas/userSaga.js
  47. 2
      packages/concordia-app/src/views/Home/index.jsx
  48. 4
      packages/concordia-app/src/views/Profile/GeneralTab/index.jsx
  49. 2
      packages/concordia-app/src/views/Profile/index.jsx
  50. 4
      packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx
  51. 2
      packages/concordia-app/src/views/Register/SignUpStep/index.jsx
  52. 10
      packages/concordia-app/src/views/Topic/TopicCreate/index.jsx
  53. 8
      packages/concordia-app/src/views/Topic/TopicView/index.jsx
  54. 68
      packages/concordia-contracts/README.md
  55. 16
      packages/concordia-contracts/constants/config/defaults.js
  56. 4
      packages/concordia-contracts/package.json
  57. 19
      packages/concordia-contracts/truffle-config.js
  58. 3
      packages/concordia-rendezvous/package.json
  59. 1203
      yarn.lock

22
.dockerignore

@ -0,0 +1,22 @@
node_modules
.idea
.git
docker/
!docker/concordia-contracts/migrate.sh
!docker/concordia-contracts/test-contracts.sh
!docker/concordia-app/test-app.sh
!docker/concordia-app/nginx.conf
!docker/ganache/start-blockchain.sh
packages/*/node_modules
packages/*/dist
packages/*/coverage
# TO-NEVER-DO: exclude the build folder of the contracts package, it's needed for building the application image.
packages/concordia-app/build
Jenkinsfile
README.md
packages/*/README.md

4
.gitignore

@ -21,8 +21,12 @@ yarn-error.log*
# Docker volumes
docker/volumes
docker/ganache/volumes
docker/reports
# Env var files
docker/env/concordia.env
docker/env/contracts.env
# Misc
.env.local

37
README.md

@ -0,0 +1,37 @@
# Concordia
> A distributed forum using Blockchain, supporting direct democratic voting
## Setup
```shell script
cd apella
yarn
```
## Compile contracts
```shell script
cd packages/apella-contracts
yarn compile
```
## Run app
```shell script
cd packages/apella-app
yarn start
```
## Build app
```shell script
cd packages/apella-app
yarn build
```
## Using Docker images
This project provides docker images for a number of services required to setup Concordia, as well as for Concordia
itself.
Check out the README.md in the `./docker` directory

67
docker/Makefile

@ -0,0 +1,67 @@
PACKAGES := $(abspath ${CURDIR}/../packages)
REPORTS := $(abspath ${CURDIR}/reports)
GANACHE_VOLUMES := $(abspath ${CURDIR}/ganache/volumes)
run: compose-run build-contracts-migrate run-contracts-migrate build-app run-app
@echo "Concordia is up and running, head over to http://localhost:7777."
# Targets for building/running/stopping the blockchain and rendezvous server (using the docker-compose file)
compose-build:
@docker-compose -f ./docker-compose.yml -p concordia build
compose-run:
@docker-compose -f ./docker-compose.yml -p concordia up -d
compose-stop:
@docker-compose -f ./docker-compose.yml -p concordia down
compose-stop-clean-data:
@docker-compose -f ./docker-compose.yml -p concordia down -v
# Ganache targets
build-ganache:
@docker build ../ -f ./ganache/Dockerfile -t concordia-ganache
run-ganache:
@docker network create --driver bridge concordia_ganache_network || true &&\
docker run -d -v ${GANACHE_VOLUMES}/ganache_keys:/home/ganache_keys -p 8545:8545 --env-file=./env/ganache.docker.env --name concordia-ganache --net=concordia_ganache_network concordia-ganache:latest
run-ganache-test:
@docker network create --driver bridge concordia_ganache_test_network || true &&\
docker run --rm -d -p 8546:8546 --env-file=./env/ganache.test.docker.env --name concordia-ganache-test --net=concordia_ganache_test_network concordia-ganache:latest
# Rendezvous targets
run-rendezvous:
@docker network create --driver bridge concordia_rendezvous_network || true &&\
docker run -d -p 9090:9090 --name concordia-rendezvous libp2p/js-libp2p-webrtc-star:version-0.20.1
# Contracts targets
build-contracts:
@docker build ../ -f ./concordia-contracts/Dockerfile --target compile -t concordia-contracts --build-arg TZ=Europe/Athens
build-contracts-migrate:
@docker build ../ -f ./concordia-contracts/Dockerfile -t concordia-contracts-migrate --build-arg TZ=Europe/Athens
build-contracts-tests:
@docker build ../ -f ./concordia-contracts/Dockerfile --target test -t concordia-contracts-tests --build-arg TZ=Europe/Athens
run-contracts-tests:
@docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.docker.env --net=concordia_ganache_test_network concordia-contracts-tests:latest
run-contracts-tests-host-chain:
@docker run --rm -v ${REPORTS}/contracts/:/usr/test-reports/ --env-file=./env/contracts.env --net=host concordia-contracts-tests:latest
run-contracts-migrate:
@docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.docker.env --net=concordia_ganache_network concordia-contracts-migrate:latest
run-contracts-migrate-host-chain:
@docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/usr/src/concordia/packages/concordia-contracts/build/ --env-file=./env/contracts.env --net=host concordia-contracts-migrate:latest
get-contracts:
@docker run --rm -v ${PACKAGES}/concordia-contracts/build/:/build --entrypoint=sh concordia-contracts:latest -c 'cp /usr/src/concordia/packages/concordia-contracts/build/* /build'
# App targets
build-app:
@docker build ../ -f ./concordia-app/Dockerfile -t concordia-app --build-arg TZ=Europe/Athens
build-app-tests:
@docker build ../ -f ./concordia-app/Dockerfile --target test -t concordia-app-tests --build-arg TZ=Europe/Athens
run-app-tests:
@docker run --rm -v ${REPORTS}/app/:/usr/test-reports/ --env-file=./env/concordia.docker.env concordia-app-tests:latest
run-app:
@docker create --env-file=./env/concordia.docker.env -p 7777:80 --name concordia-app --net=concordia_ganache_network concordia-app:latest &&\
docker network connect concordia_rendezvous_network concordia-app &&\
docker start concordia-app
run-app-host-chain:
@docker run -d --env-file=./env/concordia.env --name concordia-app --net=host concordia-app:latest
# Other
clean-images:
@docker rmi `docker images -q -f "dangling=true"`

204
docker/README.md

@ -0,0 +1,204 @@
# Concordia Dockerized
This page provides information about the provided docker images, their configuration and supported deployment
strategies.
TLDR: head down to [Putting it all together/Scripts](#piat-mkfile-targets) for a quick setup.
## Services
Concordia requires at the minimum two services to work, a blockchain and a rendezvous server.
Additionally, the Concordia application code must be provided to the user. Currently, the only way of distributing the
application code is via a webserver as a web application.
### Ganache
Ganache is a personal blockchain software used during development. It is a very convenient way of developing and testing
dApps. More information can be found in the project's [website](https://www.trufflesuite.com/ganache).
Note that any other Ethereum compliant blockchain can be used.
### Rendezvous
Concordia uses a distributed database to store forum data. A rendezvous server is needed in order for users to discover
peers in the network and get access to the data.
### Application
The Concordia application is a React app that handles interactions with the contracts and the distributed database used.
## Docker images
This repository provides docker images to easily setup (and destroy) instances of all required services Concordia.
Furthermore, we provide an image that builds the contracts and handles their migration to the blockchain in use.
### Ganache
The Dockerfile is provided in the path `./ganache`. The image makes use of the environment variables described
bellow.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| ACCOUNTS_NUMBER | 10 | Set the number of accounts generated |
| ACCOUNTS_ETHER | 100 | Set the amount of ETH assigned to each account |
| MNEMONIC | NaN | The mnemonic phrase sued as a seed for deterministic account generation |
| HOST | 0.0.0.0 | The hostname to listen on |
| PORT | 8545 | The port to listen on |
| NETWORK_ID | 5778 | The network id used to identify ganache |
Note that the Ganache instance running inside the container will save the generated blockchain keys in the path
`/home/ganache_keys/keys.json`. If you need to access the keys (eg for getting a private key and importing in Metamask)
you can mount a volume to this path to have easier access.
Also, the database used by Ganache for storing blockchain information is placed in the path `/home/ganache_db/`. You can
maintain the blockchain state between runs by mounting a volume to the database path. To do that, add the docker flag
`-v host/absolute/path/to/ganache_db:/home/ganache_db`.
### Rendezvous
The rendezvous server used here is `js-libp2p-webrtc-star`. The server listens on port 9090. More information can be
found on the github page of the project [here](https://github.com/libp2p/js-libp2p-webrtc-star).
### Contracts
This is a provision system that compiles and deploys the contracts to any Ethereum blockchain.
A Dockerfile is provided in the path `./concordia-contracts` that will build the contracts used by Concordia and
handle their deployment to any Ethereum network defined using env-vars upon container run. Dockerfile contains three
useful stages, described in the table bellow.
| Stage name | Entrypoint | Usage |
| --- | --- | --- |
| compile | Exits immediately | Compiles the contracts |
| test | Runs contract tests | Compiles contracts and runs tests using blockchain defined by env vars |
| runtime | Migrates contracts | Compiles contracts and migrates to the blockchain defined by env vars. Does **not** run tests |
The image makes use of the environment variables described bellow.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| MIGRATE_NETWORK | develop | Set the network where the contracts will be deployed/tested (set this to "env" unless you know what you're doing) |
| DEPLOY_CHAIN_HOST | NaN | Set the hostname of the blockchain network that will be used for deployment (requires network to be "env") |
| DEPLOY_CHAIN_PORT | NaN | Set the port of the blockchain network that will be used for deployment (requires network to be "env") |
| TEST_CHAIN_HOST | NaN | Set the hostname of the blockchain network that will be used for testing (requires network to be "env") |
| TEST_CHAIN_PORT | NaN | Set the port of the blockchain network that will be used for testing (requires network to be "env") |
You can find the contract artifacts in the directory `/usr/src/concordia/packages/concordia-contracts/build/` inside
the image.
**Attention**: make sure the targeted blockchain is up and running before trying to migrate the contracts.
### Application
The Dockerfile provided in the path `./concordia-application` builds the application for production and serves
the resulting build using an nginx server. Dockerfile contains two useful stages, described in the table bellow.
| Stage name | Entrypoint | Usage |
| --- | --- | --- |
| test | Runs tests | Fetches npm packages and runs tests |
| runtime | Serves application | Builds for production and serves it through nginx |
The image makes use of the environment variables described bellow.
| Environment variable | Default value | Usage |
| --- | --- | --- |
| REACT_APP_RENDEZVOUS_HOST | 127.0.0.1 | Set the hostname of the rendezvous server |
| REACT_APP_RENDEZVOUS_PORT | 9090 | Set the port of the rendezvous server |
**Attention**: this image will copy the contract artifacts from the directory `/packages/concordia-contracts/build`.
The image is bound the these artifacts after build. If the contracts change or get re-deployed the image must be
re-built to use the new artifacts.
**Attention**: make sure the contracts have been deployed before **building** this image. Also, make sure the rendezvous
server is up and running.
## Docker Compose
A docker-compose file also is provided. The docker-compose handles the lifecycle of the Ganache and Rendezvous server
containers.
## Putting it all together
You can find some ready to use scripts for common scenarios like dev deploys and testing in the `./docker` directory.
These scripts are documented in the following chapters.
### <a name="piat-mkfile-targets"></a> Makefile targets
Concordia uses blockchain and other distributed technologies. There are a number of ways to set up a running instance of
this application.
This chapter will guide you through simple setups for testing and production that depend on local blockchain (ganache)
instances which do not require real ETH to work or have any other charges.
#### Testing the contracts
Build the ganache image and spin up a blockchain for testing:
```shell
make build-ganache run-ganache-test
```
Build the testing stage of the contracts image:
```shell
make build-contracts-tests
```
Run the tests:
```shell
make run-contracts-tests
```
The results should be printed in the terminal, but are also available in the directory `./reports/contracts`.
#### Testing the application
Build the testing stage of the application image:
```shell
make build-app-tests
```
Run the test:
```shell
make run-app-tests
```
The results should be printed in the terminal, but are also available in the directory `./reports/app`.
#### Production
Just run the target:
```shell
make run
```
And you' re done! Head to [localhost:7777](localhost:7777) and voilà, a working Concordia instance appears! The
blockchain is exposed in the address `localhost:8545`.
**Tip**: the accounts (private keys) generated by Ganache are available in the file `./volumes/ganache_keys/keys.json`.
Note that the `make run` command might take several minutes to execute (depending on your system). What happens under
the hood is that:
- the ganache image is built
- blockchain and rendezvous server containers are started
- migration stage of the contracts image is built
- the contracts are deployed to the blockchain:
- the application image is built and then deployed
### Env Files
Targets in the Makefile make use of env files suffixed by `.docker` located in the directory `./env`. Using this
environment variables, you can change various configuration options of the testing/production deploys.
Targets suffixed with `host-chain` will try to use a blockchain and rendezvous server running in the host machine. They
use the `--net=host` docker option and get the required environment variables from different env files,
`./env/contracts.env` and `./env/concordia.env` (notice these env files don't include the `.docker`). These env files do
not exist by default. The values set will largely depend on how you choose to run services in your system (which ports
you use etc.), so be sure to create them before running any `host-chain` target. Luckily example files are provided.

72
docker/concordia-app/Dockerfile

@ -0,0 +1,72 @@
# --------------------------------------------------
# Stage 1 (Init application build base)
# --------------------------------------------------
FROM node:14-buster as base
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>"
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>"
LABEL gr.thmmy.ecentrics.concordia-image.name="app"
WORKDIR /usr/src/concordia
# Copy the root package.json and yarn.lock
COPY ./package.json .
COPY ./yarn.lock .
# Copy package.json files from contracts and app, then install base modules
COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/package.json
COPY ./packages/concordia-app/package.json ./packages/concordia-app/
RUN yarn install --frozen-lockfile
# Gets the rest of the source code
COPY ./packages/concordia-contracts ./packages/concordia-contracts
COPY ./packages/concordia-app ./packages/concordia-app
# --------------------------------------------------
# Stage 2 (Test)
# --------------------------------------------------
FROM base as test
# Fix timezome (needed for timestamps on report files)
ARG TZ
ENV TZ=${TZ}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /opt/concordia-app
COPY ./docker/concordia-app/test-app.sh .
WORKDIR /usr/src/concordia/packages/concordia-app
ENTRYPOINT ["/opt/concordia-app/test-app.sh"]
# --------------------------------------------------
# Stage 3 (Build)
# --------------------------------------------------
FROM base as build
WORKDIR /usr/src/concordia/packages/concordia-app
RUN yarn build
# --------------------------------------------------
# Stage 4 (Runtime)
# --------------------------------------------------
FROM nginx:1.17-alpine as runtime
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>"
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com"
LABEL gr.thmmy.ecentrics.concordia-image.name="app"
# Fix timezome
ARG TZ
RUN apk add -U tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apk del tzdata \
&& rm -rf /var/cache/apk/*
WORKDIR "/var/www/concordia-app"
COPY ./docker/concordia-app/nginx.conf /etc/nginx/conf.d/default.conf
COPY --chown=nginx:nginx --from=build /usr/src/concordia/packages/concordia-app/build .

22
docker/concordia-app/nginx.conf

@ -0,0 +1,22 @@
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/concordia-app;
index index.html index.htm;
try_files "$uri" "$uri/" /index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

11
docker/concordia-app/test-app.sh

@ -0,0 +1,11 @@
#!/bin/sh
yarn lint -f html -o /usr/test-reports/concordia-app-eslint.html --no-color
if [ $? -eq 0 ]; then
echo "TESTS RAN SUCCESSFULLY!"
exit 0
else
echo "SOME TESTS FAILED!"
exit 1
fi

66
docker/concordia-contracts/Dockerfile

@ -0,0 +1,66 @@
# --------------------------------------------------
# Stage 1 (Init contracts build base)
# --------------------------------------------------
FROM node:14-alpine as base
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>"
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>"
LABEL gr.thmmy.ecentrics.concordia-image.name="contracts"
# Fix timezome (needed for timestamps on report files)
ARG TZ
RUN apk add -U tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& apk del tzdata \
&& rm -rf /var/cache/apk/*
WORKDIR /usr/src/concordia
# Copy the root package.json and yarn.lock
COPY ./package.json .
COPY ./yarn.lock .
# Copy the contracts package.json, then install modules
COPY ./packages/concordia-contracts/package.json ./packages/concordia-contracts/
RUN yarn install --frozen-lockfile --network-timeout 100000
# Gets the rest of the source code
COPY ./packages/concordia-contracts ./packages/concordia-contracts
# --------------------------------------------------
# Stage 2 (Compile)
# --------------------------------------------------
FROM base as compile
WORKDIR /usr/src/concordia/packages/concordia-contracts
RUN yarn compile
# --------------------------------------------------
# Stage 3 (Test)
# --------------------------------------------------
FROM compile as test
WORKDIR /opt/concordia-contracts
COPY ./docker/concordia-contracts/test-contracts.sh .
WORKDIR /usr/src/concordia/packages/concordia-contracts
ENTRYPOINT ["/opt/concordia-contracts/test-contracts.sh"]
# --------------------------------------------------
# Stage 4 (Runtime)
# --------------------------------------------------
FROM compile as runtime
LABEL maintainers.1="Apostolos Fanakis <apostolof@auth.gr>"
LABEL maintainers.2="Panagiotis Nikolaidis <ezerous@gmail.com>"
LABEL gr.thmmy.ecentrics.concordia-image.name="contracts"
WORKDIR /opt/concordia-contracts
COPY ./docker/concordia-contracts/migrate.sh .
RUN ["chmod", "+x", "/opt/concordia-contracts/migrate.sh"]
ENTRYPOINT ["/opt/concordia-contracts/migrate.sh"]

6
docker/concordia-contracts/migrate.sh

@ -0,0 +1,6 @@
#!/bin/sh
export CHAIN_HOST="$DEPLOY_CHAIN_HOST"
export CHAIN_PORT="$DEPLOY_CHAIN_PORT"
cd /usr/src/concordia/packages/concordia-contracts && yarn _migrate --network "${MIGRATE_NETWORK}" --reset

16
docker/concordia-contracts/test-contracts.sh

@ -0,0 +1,16 @@
#!/bin/sh
export CHAIN_HOST="$TEST_CHAIN_HOST"
export CHAIN_PORT="$TEST_CHAIN_PORT"
yarn _eslint -f html -o /usr/test-reports/concordia-contracts-eslint.html --no-color &&
(yarn _solhint >/usr/test-reports/concordia-contracts-solhint.report) &&
(yarn test --network env >/usr/test-reports/concordia-contracts-truffle-tests.report)
if [ $? -eq 0 ]; then
echo "TESTS RAN SUCCESSFULLY!"
exit 0
else
echo "SOME TESTS FAILED!"
exit 1
fi

34
docker/docker-compose.yml

@ -0,0 +1,34 @@
version: '3.8'
services:
ganache:
build:
context: ../
dockerfile: ./docker/ganache/Dockerfile
image: concordia-ganache
container_name: concordia-ganache
env_file:
- env/ganache.docker.env
expose:
- 8545
ports:
- 8545:8545
user: root
volumes:
- ./ganache/volumes/ganache_keys:/home/ganache_keys
networks:
ganache_network:
restart: always
rendezvous:
image: libp2p/js-libp2p-webrtc-star:version-0.20.1
container_name: concordia-rendezvous
networks:
rendezvous_network:
ports:
- 9090:9090
restart: always
networks:
ganache_network:
rendezvous_network:

7
docker/env/concordia.docker.env

@ -0,0 +1,7 @@
# Variables needed in runtime (in browser)
REACT_APP_RENDEZVOUS_HOST=rendezvous
REACT_APP_RENDEZVOUS_PORT=9090
# If the rendezvous server is running on host use these instead
#REACT_APP_RENDEZVOUS_HOST=127.0.0.1
#REACT_APP_RENDEZVOUS_PORT=9090

20
docker/env/concordia.example.env

@ -0,0 +1,20 @@
# Set to "CI" if in CI environment, anything else (including unset) will be ignored
BUILD_ENV={CI}
# Docker compose variables
VIRTUAL_HOST=example.com
VIRTUAL_PORT=3000
# If you uncomment the lines below, Concordia will become available through https BUT the rendezvous
# server will stop working and IPFS initialization won't complete
#LETSENCRYPT_HOST=example.com
#LETSENCRYPT_EMAIL=someemail.email.com
# Variables needed in runtime
# TO-NEVER-DO: change CONCORDIA_HOST to localhost
CONCORDIA_HOST=0.0.0.0
CONCORDIA_PORT=3000
# Variables needed in runtime (in browser)
REACT_APP_RENDEZVOUS_HOST=xx.xxx.xxx.xxx
REACT_APP_RENDEZVOUS_PORT=9090

14
docker/env/contracts.docker.env

@ -0,0 +1,14 @@
# Variables needed in runtime
MIGRATE_NETWORK=env
DEPLOY_CHAIN_HOST=concordia-ganache
DEPLOY_CHAIN_PORT=8545
TEST_CHAIN_HOST=concordia-ganache-test
TEST_CHAIN_PORT=8546
# If the blockchain is running on host use these instead
#DEPLOY_CHAIN_HOST=127.0.0.1
#DEPLOY_CHAIN_PORT=8545
#TEST_CHAIN_HOST=127.0.0.1
#TEST_CHAIN_PORT=8546

7
docker/env/contracts.example.env

@ -0,0 +1,7 @@
# Variables needed in runtime
MIGRATE_NETWORK=env
DEPLOY_CHAIN_HOST=xx.xxx.xxx.xxx
DEPLOY_CHAIN_PORT=8545
TEST_CHAIN_HOST=xx.xxx.xxx.xxx
TEST_CHAIN_PORT=8545

5
docker/env/ganache.docker.env

@ -0,0 +1,5 @@
ACCOUNTS_NUMBER=10
ACCOUNTS_ETHER=100
HOST=0.0.0.0
PORT=8545
NETWORK_ID=5778

6
docker/env/ganache.test.docker.env

@ -0,0 +1,6 @@
ACCOUNTS_NUMBER=5
ACCOUNTS_ETHER=1
MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect"
HOST=0.0.0.0
PORT=8546
NETWORK_ID=5778

10
docker/ganache/Dockerfile

@ -0,0 +1,10 @@
FROM trufflesuite/ganache-cli:latest
RUN mkdir /home/ganache_db /home/ganache_keys
WORKDIR /opt/concordia-ganache
COPY ./docker/ganache/start-blockchain.sh .
RUN ["chmod", "+x", "/opt/concordia-ganache/start-blockchain.sh"]
ENTRYPOINT ["/opt/concordia-ganache/start-blockchain.sh"]

37
docker/ganache/start-blockchain.sh

@ -0,0 +1,37 @@
#!/bin/sh
N_ACCOUNTS="${ACCOUNTS_NUMBER:-10}"
ETHER="${ACCOUNTS_ETHER:-10}"
HOST="${HOST:-"0.0.0.0"}"
PORT="${PORT:-8545}"
ID="${NETWORK_ID:-5778}"
if [ -z "${MNEMONIC}" ]; then
echo "Starting Ganache with non deterministic address generation"
node /app/ganache-core.docker.cli.js \
--accounts "$N_ACCOUNTS" \
--defaultBalanceEther "$ETHER" \
--host "$HOST" \
--port "$PORT" \
--networkId "$ID" \
--account_keys_path "/home/ganache_keys/keys.json" \
--db "/home/ganache_db/" \
--allowUnlimitedContractSize \
--noVMErrorsOnRPCResponse \
--verbose
else
echo "Starting Ganache with deterministic address generation"
node /app/ganache-core.docker.cli.js \
--accounts "$N_ACCOUNTS" \
--defaultBalanceEther "$ETHER" \
--mnemonic "$MNEMONIC" \
--host "$HOST" \
--port "$PORT" \
--networkId "$ID" \
--account_keys_path "/home/ganache_keys/keys.json" \
--db "/home/ganache_db/" \
--allowUnlimitedContractSize \
--noVMErrorsOnRPCResponse \
--deterministic \
--verbose
fi

11
package.json

@ -1,8 +1,13 @@
{
"name": "apella",
"name": "concordia",
"private": true,
"workspaces": {
"packages": ["packages/*"],
"nohoist": ["**/web3", "**/web3/**"]
"packages": [
"packages/*"
],
"nohoist": [
"**/web3",
"**/web3/**"
]
}
}

0
packages/concordia-app/.dockerignore

12
packages/concordia-app/.env.development.example

@ -0,0 +1,12 @@
# This is an example development configuration for the app
# To create your own configuration, copy this one and ommit the ".example" from the filename, then change the
# environment cariables to the prefered values.
# Node dev-server host & port
HOST=localhost
PORT=7000
# Variables needed in runtime (in browser)
# Carefull, IPFS won't accept localhost as a valid hostname
REACT_APP_RENDEZVOUS_HOST=localhost
REACT_APP_RENDEZVOUS_PORT=9090

18
packages/concordia-app/.gitignore

@ -0,0 +1,18 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

4
packages/concordia-app/public/manifest.json

@ -1,6 +1,6 @@
{
"short_name": "Apella",
"name": "Apella",
"short_name": "Concordia",
"name": "Concordia",
"icons": [
{
"src": "favicon.ico",

2
packages/concordia-app/src/components/InitializationScreen/index.jsx

@ -5,7 +5,7 @@ import CustomLoader from './CustomLoader';
// CSS
import '../../assets/css/loading-component.css';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
const InitializationLoader = ({ children }) => {
const initializing = useSelector((state) => state.drizzleStatus.initializing);

10
packages/concordia-app/src/components/PostCreate/index.jsx

@ -8,15 +8,15 @@ import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import determineKVAddress from '../../utils/orbitUtils';
import { POSTS_DATABASE, USER_DATABASE } from '../../constants/OrbitDatabases';
import { POSTS_DATABASE, USER_DATABASE } from '../../constants/orbit/OrbitDatabases';
import { FETCH_USER_DATABASE } from '../../redux/actions/peerDbReplicationActions';
import { USER_PROFILE_PICTURE } from '../../constants/UserDatabaseKeys';
import { USER_PROFILE_PICTURE } from '../../constants/orbit/UserDatabaseKeys';
import { breeze, drizzle } from '../../redux/store';
import './styles.css';
import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../constants/TransactionStatus';
import { POST_CONTENT } from '../../constants/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { POST_CREATED_EVENT } from '../../constants/ForumContractEvents';
import { POST_CONTENT } from '../../constants/orbit/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
import { POST_CREATED_EVENT } from '../../constants/contracts/events/ForumContractEvents';
const { contracts: { [FORUM_CONTRACT]: { methods: { createPost } } } } = drizzle;
const { orbit } = breeze;

8
packages/concordia-app/src/components/PostList/PostListRow/index.jsx

@ -12,11 +12,11 @@ import { Link } from 'react-router-dom';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store';
import './styles.css';
import { POSTS_DATABASE, USER_DATABASE } from '../../../constants/OrbitDatabases';
import { POSTS_DATABASE, USER_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import determineKVAddress from '../../../utils/orbitUtils';
import { USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys';
import { POST_CONTENT } from '../../../constants/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/ContractNames';
import { USER_PROFILE_PICTURE } from '../../../constants/orbit/UserDatabaseKeys';
import { POST_CONTENT } from '../../../constants/orbit/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/contracts/ContractNames';
const { orbit } = breeze;

2
packages/concordia-app/src/components/PostList/index.jsx

@ -6,7 +6,7 @@ import { useSelector } from 'react-redux';
import { Dimmer, Feed, Loader } from 'semantic-ui-react';
import PostListRow from './PostListRow';
import { drizzle } from '../../redux/store';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
const { contracts: { [FORUM_CONTRACT]: { methods: { getPost: { cacheCall: getPostChainData } } } } } = drizzle;

8
packages/concordia-app/src/components/TopicList/TopicListRow/index.jsx

@ -13,11 +13,11 @@ import { Link } from 'react-router-dom';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store';
import './styles.css';
import { TOPICS_DATABASE, USER_DATABASE } from '../../../constants/OrbitDatabases';
import { TOPICS_DATABASE, USER_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import determineKVAddress from '../../../utils/orbitUtils';
import { USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../../constants/TopicsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/ContractNames';
import { USER_PROFILE_PICTURE } from '../../../constants/orbit/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../../constants/orbit/TopicsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/contracts/ContractNames';
const { orbit } = breeze;

2
packages/concordia-app/src/components/TopicList/index.jsx

@ -6,7 +6,7 @@ import { useSelector } from 'react-redux';
import { List } from 'semantic-ui-react';
import TopicListRow from './TopicListRow';
import { drizzle } from '../../redux/store';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
const { contracts: { [FORUM_CONTRACT]: { methods: { getTopic: { cacheCall: getTopicChainData } } } } } = drizzle;

2
packages/concordia-app/src/constants/PlaceholderTypes.js

@ -1,2 +0,0 @@
export const PLACEHOLDER_TYPE_TOPIC = 'PLACEHOLDER_TYPE_TOPIC';
export const PLACEHOLDER_TYPE_POST = 'PLACEHOLDER_TYPE_POST';

7
packages/concordia-app/src/constants/configuration/defaults.js

@ -0,0 +1,7 @@
export const WEB3_HOST_DEFAULT = '127.0.0.1';
export const WEB3_PORT_DEFAULT = '8545';
export const WEB3_PORT_SOCKET_TIMEOUT_DEFAULT = 30000;
export const WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT = 3;
export const REACT_APP_RENDEZVOUS_HOST_DEFAULT = '127.0.0.1';
export const REACT_APP_RENDEZVOUS_PORT_DEFAULT = '9090';

0
packages/concordia-app/src/constants/ContractNames.js → packages/concordia-app/src/constants/contracts/ContractNames.js

0
packages/concordia-app/src/constants/ForumContractEvents.js → packages/concordia-app/src/constants/contracts/events/ForumContractEvents.js

8
packages/concordia-app/src/constants/contracts/events/index.js

@ -0,0 +1,8 @@
import { FORUM_CONTRACT } from '../ContractNames';
import forumContractEvents from './ForumContractEvents';
const appEvents = {
[FORUM_CONTRACT]: forumContractEvents,
};
export default appEvents;

0
packages/concordia-app/src/constants/OrbitDatabases.js → packages/concordia-app/src/constants/orbit/OrbitDatabases.js

0
packages/concordia-app/src/constants/PostsDatabaseKeys.js → packages/concordia-app/src/constants/orbit/PostsDatabaseKeys.js

0
packages/concordia-app/src/constants/TopicsDatabaseKeys.js → packages/concordia-app/src/constants/orbit/TopicsDatabaseKeys.js

0
packages/concordia-app/src/constants/UserDatabaseKeys.js → packages/concordia-app/src/constants/orbit/UserDatabaseKeys.js

11
packages/concordia-app/src/options/breezeOptions.js

@ -1,5 +1,12 @@
import { EthereumContractIdentityProvider } from '@ezerous/eth-identity-provider';
import databases from '../constants/OrbitDatabases';
import databases from '../constants/orbit/OrbitDatabases';
import {
REACT_APP_RENDEZVOUS_HOST_DEFAULT,
REACT_APP_RENDEZVOUS_PORT_DEFAULT,
} from '../constants/configuration/defaults';
const REACT_APP_RENDEZVOUS_HOST = process.env.REACT_APP_RENDEZVOUS_HOST || REACT_APP_RENDEZVOUS_HOST_DEFAULT;
const REACT_APP_RENDEZVOUS_PORT = process.env.REACT_APP_RENDEZVOUS_PORT || REACT_APP_RENDEZVOUS_PORT_DEFAULT;
const breezeOptions = {
ipfs: {
@ -8,7 +15,7 @@ const breezeOptions = {
Swarm: [
// Use local signaling server (see also rendezvous script in package.json)
// For more information: https://github.com/libp2p/js-libp2p-webrtc-star
'/ip4/127.0.0.1/tcp/9090/wss/p2p-webrtc-star',
`/ip4/${REACT_APP_RENDEZVOUS_HOST}/tcp/${REACT_APP_RENDEZVOUS_PORT}/wss/p2p-webrtc-star`,
// Use the following public servers if needed
// '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',

13
packages/concordia-app/src/options/drizzleOptions.js

@ -1,17 +1,12 @@
// See also: https://truffleframework.com/docs/drizzle/reference/drizzle-options
// Check out the documentation: https://truffleframework.com/docs/drizzle/reference/drizzle-options
import { contracts } from 'concordia-contracts';
import web3Options from './web3Options';
import forumContractEvents from '../constants/ForumContractEvents';
import { FORUM_CONTRACT } from '../constants/ContractNames';
import appEvents from '../constants/contracts/events';
const drizzleOptions = {
web3: {
customProvider: web3Options.web3,
},
web3: web3Options,
contracts,
events: {
[FORUM_CONTRACT]: forumContractEvents,
},
events: { ...appEvents },
reloadWindowOnNetworkChange: true,
reloadWindowOnAccountChange: true, // We need it to reinitialize breeze and create new Orbit databases
};

27
packages/concordia-app/src/options/web3Options.js

@ -1,14 +1,29 @@
import Web3 from 'web3';
import {
WEB3_HOST_DEFAULT,
WEB3_PORT_DEFAULT,
WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT,
WEB3_PORT_SOCKET_TIMEOUT_DEFAULT,
} from '../constants/configuration/defaults';
const { WEB3_URL, WEB3_PORT } = process.env;
const { WEB3_HOST, WEB3_PORT, WEBSOCKET_TIMEOUT } = process.env;
// We need fallback ws://127.0.0.1:8545 because drizzle has not the patched web3 we use here
const web3 = (WEB3_URL && WEB3_PORT)
? `ws://${WEB3_URL}:${WEB3_PORT}`
: new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider('ws://127.0.0.1:8545'));
const web3WebsocketOptions = {
keepAlive: true,
timeout: WEBSOCKET_TIMEOUT !== undefined ? WEBSOCKET_TIMEOUT : WEB3_PORT_SOCKET_TIMEOUT_DEFAULT,
reconnect: {
maxAttempts: WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT,
},
};
const web3 = (WEB3_HOST !== undefined && WEB3_PORT !== undefined)
? `ws://${WEB3_HOST}:${WEB3_PORT}`
: new Web3(Web3.givenProvider || new Web3.providers.WebsocketProvider(
`ws://${WEB3_HOST_DEFAULT}:${WEB3_PORT_DEFAULT}`, web3WebsocketOptions,
));
const web3Options = {
web3,
customProvider: web3,
};
export default web3Options;

2
packages/concordia-app/src/redux/actions/contractEventActions.js

@ -3,7 +3,7 @@ import {
TOPIC_CREATED_EVENT,
USER_SIGNED_UP_EVENT,
USERNAME_UPDATED_EVENT,
} from '../../constants/ForumContractEvents';
} from '../../constants/contracts/events/ForumContractEvents';
export const FORUM_EVENT_USER_SIGNED_UP = 'FORUM_EVENT_USER_SIGNED_UP';
export const FORUM_EVENT_USERNAME_UPDATED = 'FORUM_EVENT_USERNAME_UPDATED';

8
packages/concordia-app/src/redux/sagas/peerDbReplicationSaga.js

@ -9,10 +9,10 @@ import {
} from '@ezerous/breeze/src/orbit/orbitActions';
import determineKVAddress from '../../utils/orbitUtils';
import { FETCH_USER_DATABASE, UPDATE_ORBIT_DATA } from '../actions/peerDbReplicationActions';
import { POSTS_DATABASE, TOPICS_DATABASE, USER_DATABASE } from '../../constants/OrbitDatabases';
import userDatabaseKeys from '../../constants/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../constants/TopicsDatabaseKeys';
import { POST_CONTENT } from '../../constants/PostsDatabaseKeys';
import { POSTS_DATABASE, TOPICS_DATABASE, USER_DATABASE } from '../../constants/orbit/OrbitDatabases';
import userDatabaseKeys from '../../constants/orbit/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../constants/orbit/TopicsDatabaseKeys';
import { POST_CONTENT } from '../../constants/orbit/PostsDatabaseKeys';
function* fetchUserDb({ orbit, userAddress, dbName }) {
const peerDbAddress = yield call(determineKVAddress, {

2
packages/concordia-app/src/redux/sagas/userSaga.js

@ -5,7 +5,7 @@ import {
import { drizzleActions } from '@ezerous/drizzle';
import { USER_DATA_UPDATED, USER_DATA_ERROR } from '../actions/userActions';
import { FORUM_EVENT_USER_SIGNED_UP } from '../actions/contractEventActions';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
function* fetchUserData({ drizzle, account }) {
const contract = drizzle.contracts[FORUM_CONTRACT];

2
packages/concordia-app/src/views/Home/index.jsx

@ -6,7 +6,7 @@ import { useSelector } from 'react-redux';
import Board from './Board';
import './styles.css';
import { drizzle } from '../../redux/store';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
const { contracts: { [FORUM_CONTRACT]: { methods: { getNumberOfTopics } } } } = drizzle;

4
packages/concordia-app/src/views/Profile/GeneralTab/index.jsx

@ -7,10 +7,10 @@ import moment from 'moment';
import { useDispatch, useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';
import determineKVAddress from '../../../utils/orbitUtils';
import databases, { USER_DATABASE } from '../../../constants/OrbitDatabases';
import databases, { USER_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import { breeze } from '../../../redux/store';
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys';
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../constants/orbit/UserDatabaseKeys';
import './styles.css';
const { orbit } = breeze;

2
packages/concordia-app/src/views/Profile/index.jsx

@ -6,7 +6,7 @@ import { useSelector } from 'react-redux';
import { useHistory, useRouteMatch } from 'react-router';
import { useTranslation } from 'react-i18next';
import { drizzle } from '../../redux/store';
import { FORUM_CONTRACT } from '../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../constants/contracts/ContractNames';
import CustomLoadingTabPane from '../../components/CustomLoadingTabPane';
import TopicList from '../../components/TopicList';
import PostList from '../../components/PostList';

4
packages/concordia-app/src/views/Register/PersonalInformationStep/index.jsx

@ -10,8 +10,8 @@ import { useHistory } from 'react-router';
import checkUrlValid from '../../../utils/urlUtils';
import { breeze } from '../../../redux/store';
import './styles.css';
import { USER_DATABASE } from '../../../constants/OrbitDatabases';
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys';
import { USER_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import { USER_LOCATION, USER_PROFILE_PICTURE } from '../../../constants/orbit/UserDatabaseKeys';
const { orbit: { stores } } = breeze;

2
packages/concordia-app/src/views/Register/SignUpStep/index.jsx

@ -11,7 +11,7 @@ import { useHistory } from 'react-router';
import PropTypes from 'prop-types';
import { drizzle } from '../../../redux/store';
import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../../constants/TransactionStatus';
import { FORUM_CONTRACT } from '../../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../../constants/contracts/ContractNames';
const { contracts: { [FORUM_CONTRACT]: { methods: { isUserNameTaken, signUp } } } } = drizzle;

10
packages/concordia-app/src/views/Topic/TopicCreate/index.jsx

@ -10,11 +10,11 @@ import { useSelector } from 'react-redux';
import './styles.css';
import { drizzle, breeze } from '../../../redux/store';
import { TRANSACTION_ERROR, TRANSACTION_SUCCESS } from '../../../constants/TransactionStatus';
import { POSTS_DATABASE, TOPICS_DATABASE } from '../../../constants/OrbitDatabases';
import { TOPIC_SUBJECT } from '../../../constants/TopicsDatabaseKeys';
import { POST_CONTENT } from '../../../constants/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/ContractNames';
import { TOPIC_CREATED_EVENT } from '../../../constants/ForumContractEvents';
import { POSTS_DATABASE, TOPICS_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import { TOPIC_SUBJECT } from '../../../constants/orbit/TopicsDatabaseKeys';
import { POST_CONTENT } from '../../../constants/orbit/PostsDatabaseKeys';
import { FORUM_CONTRACT } from '../../../constants/contracts/ContractNames';
import { TOPIC_CREATED_EVENT } from '../../../constants/contracts/events/ForumContractEvents';
const { contracts: { [FORUM_CONTRACT]: { methods: { createTopic } } } } = drizzle;
const { orbit: { stores } } = breeze;

8
packages/concordia-app/src/views/Topic/TopicView/index.jsx

@ -11,12 +11,12 @@ import { breeze, drizzle } from '../../../redux/store';
import { FETCH_USER_DATABASE } from '../../../redux/actions/peerDbReplicationActions';
import './styles.css';
import PostList from '../../../components/PostList';
import { TOPICS_DATABASE, USER_DATABASE } from '../../../constants/OrbitDatabases';
import { TOPICS_DATABASE, USER_DATABASE } from '../../../constants/orbit/OrbitDatabases';
import determineKVAddress from '../../../utils/orbitUtils';
import { USER_PROFILE_PICTURE } from '../../../constants/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../../constants/TopicsDatabaseKeys';
import { USER_PROFILE_PICTURE } from '../../../constants/orbit/UserDatabaseKeys';
import { TOPIC_SUBJECT } from '../../../constants/orbit/TopicsDatabaseKeys';
import PostCreate from '../../../components/PostCreate';
import { FORUM_CONTRACT } from '../../../constants/ContractNames';
import { FORUM_CONTRACT } from '../../../constants/contracts/ContractNames';
const { contracts: { [FORUM_CONTRACT]: { methods: { getTopic: { cacheCall: getTopicChainData } } } } } = drizzle;
const { orbit } = breeze;

68
packages/concordia-contracts/README.md

@ -0,0 +1,68 @@
# Concordia Contracts Package
This is the package where the contracts that power Concordia live.
## Compile contracts
```shell script
yarn compile
```
## Lint contracts (and tests)
```shell script
yarn lint
```
## Migrate contracts
Default host and port values of the blockchain are:
| host | port |
|---|---|
| 127.0.0.1 | 8545 |
Migrate (using the development network by default):
```shell script
yarn migrate
```
### Setting different host and port values
Define the host and port of the blockchain in use.
Linux:
```shell script
export CHAIN_HOST="127.0.0.1"
export CHAIN_PORT="7545"
```
Windows:
```shell script
SET CHAIN_HOST="127.0.0.1"
SET CHAIN_PORT="7545"
```
Migrate using the `env` network :
```shell script
yarn _migrate --network env
```
**Notice the underscore `_` suffix in the script name. This is not a mistake.**
## Test contracts
Default host and port values of the blockchain are:
| host | port |
|---|---|
| 127.0.0.1 | 8546 |
Test:
```shell script
yarn test
```
### Setting different host and port values
Define the host and port of the blockchain in use like above.
Test:
```shell script
yarn test --network env
```

16
packages/concordia-contracts/constants/config/defaults.js

@ -0,0 +1,16 @@
const DEVELOP_CHAIN_HOST_DEFAULT = '127.0.0.1';
const DEVELOP_CHAIN_PORT_DEFAULT = '8545';
const TEST_CHAIN_HOST_DEFAULT = '127.0.0.1';
const TEST_CHAIN_PORT_DEFAULT = '8546';
module.exports = {
develop: {
chainHost: DEVELOP_CHAIN_HOST_DEFAULT,
chainPort: DEVELOP_CHAIN_PORT_DEFAULT,
},
test: {
chainHost: TEST_CHAIN_HOST_DEFAULT,
chainPort: TEST_CHAIN_PORT_DEFAULT,
},
};

4
packages/concordia-contracts/package.json

@ -10,7 +10,9 @@
"_eslint": "yarn eslint . --format table",
"_solhint": "yarn solhint --formatter table contracts/*.sol test/*.sol",
"test": "yarn truffle test",
"migrate": "yarn truffle migrate --network develop --reset"
"migrate": "yarn _migrate --network develop",
"migrate-reset": "yarn _migrate --network develop --reset",
"_migrate": "yarn truffle migrate"
},
"dependencies": {
"@openzeppelin/contracts": "~3.2.0",

19
packages/concordia-contracts/truffle-config.js

@ -1,7 +1,9 @@
const path = require('path');
const defaults = require('./constants/config/defaults');
const { GANACHE_HOST } = process.env;
const { GANACHE_PORT } = process.env;
const {
CHAIN_HOST, CHAIN_PORT,
} = process.env;
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
@ -14,13 +16,18 @@ module.exports = {
contracts_build_directory: path.join(__dirname, 'build/'),
networks: {
develop: {
host: GANACHE_HOST || '127.0.0.1',
port: GANACHE_PORT || '8545',
host: defaults.develop.chainHost,
port: defaults.develop.chainPort,
network_id: '*',
},
test: {
host: GANACHE_HOST || '127.0.0.1',
port: GANACHE_PORT || '8546',
host: defaults.test.chainHost,
port: defaults.test.chainPort,
network_id: '*',
},
env: {
host: CHAIN_HOST,
port: CHAIN_PORT,
network_id: '*',
},
},

3
packages/concordia-rendezvous/package.json

@ -4,7 +4,8 @@
"private": true,
"description": "Rendezvous server for Concordia",
"scripts": {
"rendezvous": "star-signal --port=9090 --host=127.0.0.1"
"rendezvous": "star-signal --port=9090 --host=127.0.0.1",
"start": "star-signal --port=9090 --host=127.0.0.1"
},
"devDependencies": {
"libp2p-webrtc-star": "~0.20.1"

1203
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save