Skip to content

Commit

Permalink
Forked tbtc-dapp for tbtc.network
Browse files Browse the repository at this point in the history
Forked from keep-network/tbtc-dapp@b3a5713

Co-authored-by: Jakub Nowakowski <jakub.nowakowski@akena.co>
Co-authored-by: Taggart Bowen-Gaddy <taggartbg@gmail.com>
Co-authored-by: Antonio Salazar Cardozo <savedfastcool@gmail.com>
Co-authored-by: liamzebedee <liamzebedee@yahoo.com.au>
Co-authored-by: NicholasDotSol <45673183+NicholasDotSol@users.noreply.github.com>
  • Loading branch information
6 people committed Feb 17, 2020
0 parents commit 5b09bca
Show file tree
Hide file tree
Showing 242 changed files with 110,100 additions and 0 deletions.
160 changes: 160 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
version: 2.1

executors:
docker-node:
docker:
- image: circleci/node:11
docker-thesis-buildpack:
docker:
- image: thesisco/docker-buildpack:bionic

orbs:
gcp-gcr: circleci/gcp-gcr@0.0.4

jobs:
test_client:
executor: docker-node
working_directory: ~/project/client
steps:
- checkout:
path: ~/project

# Download and cache dependencies.
- restore_cache:
keys:
# When lock file changes, use increasingly general patterns to restore cache.
- v1-client-npm-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v1-client-npm-deps-{{ .Branch }}-
- v1-client-npm-deps-
- run: npm install
- save_cache:
key: v1-client-npm-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- node_modules

# Run tests.
- run:
name: Run NPM tests
command: npm run test:setup && npm run test

test_tbtc_helpers:
executor: docker-node
working_directory: ~/project/lib/tbtc-helpers
steps:
- checkout:
path: ~/project

# Download and cache dependencies.
- restore_cache:
keys:
# When lock file changes, use increasingly general patterns to restore cache.
- v1-helpers-npm-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v1-helpers-npm-deps-{{ .Branch }}-
- v1-helpers-npm-deps-
- run: npm install
- save_cache:
key: v1-helpers-npm-deps-{{ checksum "package-lock.json" }}
paths:
- node_modules

# Run tests.
- run:
name: Run NPM tests
command: npm test

build_dapp:
executor: docker-thesis-buildpack
steps:
- setup_remote_docker:
docker_layer_caching: false
- checkout
- run:
name: Set Gcloud Auth
command: |
echo $GCLOUD_SERVICE_KEY_GET_BUCKET_OBJECT > ~/gcloud-service-key.json
gcloud auth activate-service-account --key-file ~/gcloud-service-key.json
- run:
name: Fetch contract artifacts
command: |
./scripts/fetch-contracts.sh
- run:
name: Run Docker build
command: |
docker build -t build --target build .
docker build -t $GCR_REGISTRY_URL/$GOOGLE_PROJECT_ID/tbtc-dapp .
- run:
name: Save tbtc-dapp image
command: |
mkdir -p /tmp/tbtc-dapp/docker-images/
docker save -o /tmp/tbtc-dapp/docker-images/tbtc-dapp.tar $GCR_REGISTRY_URL/$GOOGLE_PROJECT_ID/tbtc-dapp
- persist_to_workspace:
root: /tmp/tbtc-dapp
paths:
- docker-images

publish_dapp:
executor: gcp-gcr/default
steps:
- attach_workspace:
at: /tmp/tbtc-dapp
- run:
name: Load tbtc-dapp image
command: |
docker load -i /tmp/tbtc-dapp/docker-images/tbtc-dapp.tar
- gcp-gcr/gcr-auth:
google-project-id: GOOGLE_PROJECT_ID
google-compute-zone: GOOGLE_COMPUTE_ZONE_A
# This param doesn't actually set anything, leaving here as a reminder to check when they fix it.
gcloud-service-key: GCLOUD_SERVICE_KEY
- gcp-gcr/push-image:
google-project-id: GOOGLE_PROJECT_ID
registry-url: $GCR_REGISTRY_URL
image: tbtc-dapp
tag: latest

workflows:
version: 2
client:
jobs:
- test_client
tbtc_helpers:
jobs:
- test_tbtc_helpers
dapp_keep_dev:
jobs:
- build_dapp:
context: keep-dev
- publish_dapp:
filters:
branches:
only: master
context: keep-dev
requires:
- build_dapp
dapp_keep_test:
jobs:
- keep_test_approval:
type: approval
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
- build_dapp:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context: keep-test
requires:
- keep_test_approval
- publish_dapp:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context: keep-test
requires:
- build_dapp
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "tbtc-prod"
}
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
src/app.less/
*.code-workspace
build/
.DS_Store

client/src/eth/artifacts/*.JSON
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Build environment
FROM node:11.15.0-alpine as build

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

RUN apk add --update --no-cache \
git \
build-base \
python

COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json

## Copy dependencies referenced as a file path.
COPY client/ /app/client/
COPY lib/ /app/lib/

RUN npm install

COPY . /app

RUN npm run build

# Production environment
FROM nginx:1.17-alpine

COPY --from=build /app/build /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d

EXPOSE 80

## Set `daemon off` so the nginx is run in the foreground.
CMD ["nginx", "-g", "daemon off;"]
78 changes: 78 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
:toc: macro

= tBTC dApp

toc::[]

== Development

=== Setup

The dApp requires artifacts of the contracts deployed to the development environment.
To fetch the latest artifacts run `npm run setup`. The command will download files
stored in the Google Cloud. For initial configuration of the `gcloud` please refer
to the https://github.com/keep-network/keep-core/blob/master/infrastructure/kube/keep-dev/kube-setup.org#first-time-with-this-environment[instructions].

=== Run

`npm start` runs the app in the development mode.<br>
Open http://localhost:3000[http://localhost:3000] to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

== Deployment

Currently the dApp, and its landing page, are deployed using Firebase to
tbtc.network on the `tbtc-prod` GCP project and cluster. Deploying a new build
involves two steps:

* `npm run publish` builds a static version of the site to `build/`
* `firebase deploy` deploys the contents of `build/` to firebase

If the local machine hasn't authed to firebase, `firebase deploy` should prompt
for login. If the logged in user isn't authorized to run a deploy, check to see
if that authorization can be added.

== Docker

To build a Docker image execute:
```sh
docker build . -t tbtc-dapp
```

To run the Docker image execute:
```sh
docker run -p 8080:80 tbtc-dapp
```

This will expose the app under http://localhost:8080[http://localhost:8080].

== Internal TestNet

To access the internal tBTC TestNet you need to be connected to it via VPN.
Contracts with which the app is interacting are deployed under the following
addresses:

|===
| Name | Address

| `Deposit` | 0xe94728C7572900d914178ab17D7bbc9af8C543A0
| `DepositFactory` | 0xE54dDac3bDBe943b4b76343c72C02aF5369b9Aaf
| `TBTCSystem` | 0x20c0D2C470D9Afcb3846E694a0D9d6dB5ED11a6A
| `TBTCConstants` | 0xC9435e9722509aD5AA7B01eBB2F33bdA453A6E58
| `TBTCToken` | 0x5373196E86906312c87cB7A30b9461a946DD5C82
| `ECDSAKeep` | deployed via keep factory
|===

=== MetaMask

Add custom network to your MetaMask:

[cols="1,2"]
|===
| **RPC URL**| `http://eth-tx-node.default.svc.cluster.local:8545`
| **ChainID**| `1101`
|===

NOTE: It was confirmed to work on Chrome browser, there were some problems with
connection to the custom RPC on Firefox.
14 changes: 14 additions & 0 deletions client/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry",
"corejs": 3
}
]
],
"plugins": [
["@babel/transform-runtime"]
]
}
17 changes: 17 additions & 0 deletions client/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "eslint-config-keep",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"env": {
"es6": true,
"mocha": true
},
"rules": {
"semi": [
2,
"never"
]
}
}
Loading

0 comments on commit 5b09bca

Please sign in to comment.