Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 143 fix escrow decimal #299

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .docker/firebase-emulators/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "impublic-local"
}
}
28 changes: 28 additions & 0 deletions .docker/firebase-emulators/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:16-slim
ARG BUILD_DATE
ARG FIREBASE_TOOLS_VERSION
ARG HOME
LABEL org.label-schema.schema-version="1.0" \
org.label-schema.name="firebase-tools" \
org.label-schema.version=${FIREBASE_TOOLS_VERSION} \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.description="Firebase CLI on the NodeJS image" \
org.label-schema.url="https://github.com/firebase/firebase-tools/"
EXPOSE 4000
EXPOSE 5000
EXPOSE 5001
EXPOSE 8080
EXPOSE 8085
EXPOSE 9000
EXPOSE 9005
EXPOSE 9099
EXPOSE 9199
EXPOSE 4400
SHELL ["/bin/sh", "-c"]
RUN apt-get update && apt-get install -y default-jdk python3 && \
npm install -g firebase-tools@${FIREBASE_TOOLS_VERSION} && \
npm cache clean --force && \
firebase setup:emulators:firestore && \
firebase setup:emulators:storage && \
firebase -V && \
java -version
21 changes: 21 additions & 0 deletions .docker/firebase-emulators/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"emulators": {
"storage": {
"port": 9199,
"host": "0.0.0.0"
},
"ui": {
"enabled": true,
"port": 4000,
"host": "0.0.0.0"
},
"singleProjectMode": true,
"firestore": {
"port": 8080,
"host": "0.0.0.0"
}
},
"storage": {
"rules": "storage.rules"
}
}
8 changes: 8 additions & 0 deletions .docker/firebase-emulators/storage.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
6 changes: 6 additions & 0 deletions .docker/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT 'CREATE DATABASE involvemint'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'involvemint')\gexec

SELECT 'CREATE DATABASE "involvemint-e2e"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'involvemint-e2e')\gexec

1 change: 1 addition & 0 deletions .docker/pgpass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postgres:5432:*:postgres:postgres
18 changes: 18 additions & 0 deletions .docker/servers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Servers": {
"1": {
"Name": "Involvemint Local",
"Group": "Servers",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "postgres",
"Comment": "Auto-detected PostgreSQL 12 installation with the data directory at /Library/PostgreSQL/12/data",
"ConnectionParameters": {
"sslmode": "prefer",
"connect_timeout": 10,
"passfile": "/tmp/pgpass"
}
}
}
}
10 changes: 5 additions & 5 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projects": {
"default": "involvemint2"
}
}
{
"projects": {
"default": "involvemint2"
}
}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# environment file
environment.ts

# compiled output
/dist
Expand Down Expand Up @@ -43,4 +45,7 @@ Thumbs.db
.firebase/

gcp-service-key-prod.json
gcp-api-key-prod.json
gcp-api-key-prod.json

reports/*
!reports/readme.md
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .npmrc
#engine-strict=true
149 changes: 125 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,142 @@
# Official involveMINT Web App Repository

## Setting Up Environment
## Build Prerequisites

Prerequisites:

- Nodejs
- Postgres database named `involvemint` running on localhost port 5432 with username `postgres` and password `1Qazxsw2`
- Visual Studio Code
- Node.js
- Docker

### Steps
## Steps to Set Up Environment

1. Clone repository
1. Fork and clone this repository. Ensure that you uncheck the "copy main branch only" checkbox. Once you forked the repository, clone it to a directory on your local machine and `cd` into it.

```sh
git clone [email protected]:v3/involvemint/involveMINT/involvemint2.0
```
2. Checkout the "develop" branch: `git checkout develop`.
3. Ensure you have Node.js installed. If you don't, please look at the section on [installing node.js](#installing-nodejs).
4. Ensure you have Docker installed. If you don't, please navigate to the [official website](https://docs.docker.com/get-docker/) and follow the instructions. Run `docker --version` in your terminal after it's installed to ensure you have installed everything correctly.

2. Change directory into repository
### Installing Node.js

```sh
cd involvemint2.0
```
Run the following commands.

3. Install dependencies
1. `curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash`
2. `export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"`
3. `[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"`
4. Refresh your shell (close and reopen). If you're using zsh, here's a shortcut: `source ~/.zshrc`
5. If the following command does not throw an error, you're good so far: `nvm -v`
6. `nvm install lts/gallium`
7. `nvm use lts/gallium`

```sh
npm install
```
### Configuring Firebase

4. Start client
In order to run this code, you will need to navigate to [firebase](https://console.firebase.google.com/). You will see a screen that looks like ![firebase-landing](/assets/firebase-landing.png) and click "Create a project" (if you don't already have a GCP account and an existing project where you want to use Firebase). Once you have a project, you should see a screen like ![this](assets/firebase-dashboard.png) Once here, click the little gear and you'll see a screen that looks like ![this](assets/firebase-settings.png) Select the "Service accounts" tab and you'll see a screen that looks like ![this](assets/firebase-service-accounts.png) Hit the "Manage service account permissions" hyperlink which will take you to your GCP project. You will see a screen that looks like ![this](/assets/googlecloud-service-accounts.png). Click the account and then hit the "Keys" tab. You should see a screen that looks like ![this](/assets/service-account-keys.png). Click "Add Key" and then choose the "JSON" option to download it as a JSON file.

```sh
npx ng s
```
Ensure you are in the project directory (the directory that this file is in). Run the following command: `cp libs/shared/domain/src/lib/environments/environment.ts libs/shared/domain/src/lib/environments/environment.local.ts` and open the new file (environment.prod.ts) in your editor. It should look like this at first:

5. In another terminal, start server
```typescript
import { Env } from './environment.interface';

```sh
npx ng s api
const host = 'localhost';

/** Develop environment variables. */
export const environment: Env = {
production: false,
test: false,
host,
apiUrl: `http://${host}:3335`,
appUrl: `http://${host}:4202`,
storageBucket: 'your storage bucket',
adminPasswordHash:
'sZfCJx5X3sGSwkokIs9IVFxDfxWd2lEKsAhkOSDfEK8u2YS98y5rJAmXmtrJs7AQ29xkHMmz0bDfLkXCKS9/+A==',
gcpApiKey: 'insert your key here',
typeOrmConfig: {
type: 'postgres',
host: '127.0.0.1',
port: 5433,
username: 'postgres',
password: '1Qazxsw2',
database: 'involvemint',
synchronize: true,
autoLoadEntities: true,
ssl: false,
},
firebaseEnv: {
apiKey: 'insert your key here',
authDomain: 'firebase auth domain',
databaseURL: '',
projectId: 'your project id',
storageBucket: 'Your project storage bucket', //your-something.appspot.com
messagingSenderId: '',
appId: 'your app id',
measurementId: 'Your measurementId',
},
// mailgun and twilio are optional
mailgun: {
apiKey: '',
domain: '',
},
twilio: {
accountSid: '',
authToken: '',
sendingPhone: '',
},
gcp: {
type: 'service_account',
project_id: 'project-id',
private_key_id: 'Your Private Key',
private_key: '-----BEGIN PRIVATE KEY-----\nYour Private Key\n-----END PRIVATE KEY-----\n',
client_email: 'Your client email',
client_id: 'client id',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url: 'cert url',
},
// I don't think this is used
scrypt: {
memCost: 14,
rounds: 8,
saltSeparator: 'Bw==',
signerKey: 'de/PQ/Gy53mgslvUgDUKDCgHJPArYqbFnGILLQZNe5My/CvqIThVL/CsndU8oudZ9lc4B7PT8w3sAar2/luQxA==',
},
defaultLocalAddress: [{
streetNumber: '5000',
streetName: 'Forbes Ave',
formattedAddress: '5000 Forbes Ave, Pittsburgh, PA 15213',
city: 'Pittsburgh',
administrativeLevels: {
level1short: 'PA'
},
zipcode: '15213',
latitude: 40.444229,
longitude: -79.943367
}]
};
```

Under the key "typeOrmConfig", please change the password field to "postgres". Under the key "gcp", please change the fields to match the fields in your service account JSON file that you just downloaded in the previous step.

### Starting the Containers

Run `docker compose up` in the root directory, which will spin up a PostgreSQL database on port 5433, a PgAdmin UI on port 8889, and a firestore emulator available at http://127.0.0.1:4000.

If you are prompted for the pasword (below screenshot) when opening PgAdmin at http://localhost:8889 enter `postgres`.
![postgres_db_password_required](/assets/postgres_db_password_required.png)


### Starting the Apps

- Open a terminal and run `npm i` from root directory to install all the required packages.
- Run `export FIREBASE_STORAGE_EMULATOR_HOST=localhost:9199`.
- Run `export FIRESTORE_EMULATOR_HOST='localhost:8080'`.
- Run `npm run start:client:local` which will start the client app.
- Leave that terminal open and running and open a new terminal
- In the new terminal: Run `export FIREBASE_STORAGE_EMULATOR_HOST=localhost:9199`.
- In the new terminal: Run `export FIRESTORE_EMULATOR_HOST='localhost:8080'`.
- Then Run `npm run start:server:local` which will start the server app.

Once running, the client can be accessed via `http://localhost:4202` and the api/server will be running on `http://127.0.0.1:3335`



For any issues, or to suggest improvements to this documentation, please contact Anish Sinha <<[email protected]>>
39 changes: 33 additions & 6 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@
"maximumError": "10kb"
}
]
},
"local": {
"fileReplacements":[
{
"replace": "libs/shared/domain/src/lib/environments/environment.ts",
"with": "libs/shared/domain/src/lib/environments/environment.local.ts"
}
]
}
}
},
Expand All @@ -115,6 +123,9 @@
},
"test": {
"browserTarget": "involvemint:build:test"
},
"local": {
"browserTarget": "involvemint:build:local"
}
}
},
Expand Down Expand Up @@ -158,6 +169,9 @@
},
"test": {
"devServerTarget": "involvemint:serve:test"
},
"local": {
"devServerTarget": "involvemint:serve"
}
}
},
Expand Down Expand Up @@ -205,6 +219,14 @@
"with": "libs/shared/domain/src/lib/environments/environment.test.ts"
}
]
},
"local": {
"fileReplacements":[
{
"replace": "libs/shared/domain/src/lib/environments/environment.ts",
"with": "libs/shared/domain/src/lib/environments/environment.local.ts"
}
]
}
}
},
Expand All @@ -213,6 +235,11 @@
"options": {
"buildTarget": "api:build",
"port": 2324
},
"configurations": {
"local":{
"buildTarget": "api:build:local"
}
}
},
"lint": {
Expand Down Expand Up @@ -787,22 +814,22 @@
}
}
},
"server-orcha": {
"root": "libs/server/orcha",
"sourceRoot": "libs/server/orcha/src",
"server-api": {
"root": "libs/server/api",
"sourceRoot": "libs/server/api/src",
"projectType": "library",
"architect": {
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["libs/server/orcha/**/*.ts"]
"lintFilePatterns": ["libs/server/api/**/*.ts"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/libs/server/orcha"],
"outputs": ["coverage/libs/server/api"],
"options": {
"jestConfig": "libs/server/orcha/jest.config.js",
"jestConfig": "libs/server/api/jest.config.js",
"passWithNoTests": true
}
}
Expand Down
5 changes: 4 additions & 1 deletion app.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
runtime: nodejs14
runtime: nodejs16

instance_class: F4

build_env_variables:
GOOGLE_NODE_RUN_SCRIPTS: ''
Loading