Skip to content

Commit

Permalink
Merge branch 'develop' into add-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed May 15, 2024
2 parents a2149ed + 2aa87a4 commit 987e7ee
Show file tree
Hide file tree
Showing 40 changed files with 1,052 additions and 317 deletions.
9 changes: 6 additions & 3 deletions .env → .env.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
DB_HOST=squid-db
DB_NAME=squid
DB_PORT=23798
DB_PORT=5432
GQL_PORT=4350
GQL_URL="https://graphql.mydomain.com"

# JSON-RPC node endpoints (wss or https)
# Use private endpoints in production!
# Set urls via secrets if deploying to Cloud: https://docs.subsquid.io/deploy-squid/env-variables/
# OR use the RPC proxy service: https://docs.subsquid.io/deploy-squid/rpc-proxy/
RPC_ENDPOINT=https://eth-sepolia.g.alchemy.com/v2/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
RPC_ENDPOINT=https://eth-sepolia.g.alchemy.com/v2/XXXXXXXXXXXXXXXXXXXXXXXXXX

# Uncommenting this line enables the debug mode
# More info at https://docs.subsquid.io/basics/logging/
Expand All @@ -15,4 +17,5 @@ RPC_ENDPOINT=https://eth-sepolia.g.alchemy.com/v2/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EAS_CONTRACT_ADDRESS=0xC2679fBD37d54388Ce493F1DB75320D236e1815e
SCHEMA_CONTRACT_ADDRESS=0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0

PROJECT_VERIFY_ATTESTATION_SCHEMA=0x9e55855a361f8ff089592b238c6341c880a9228521d87be3fd8fa8922d88c484
PROJECT_VERIFY_ATTESTATION_SCHEMA=0x3D5854AF182F27966DEA837C446A051B3509224DDC03150E55097B362D111B1B
PROJECT_GIVBACK_ELIGIBLE_ATTESTATION_SCHEMA=0x0000000000000000000000000000000000000000000000000000000000000000
28 changes: 28 additions & 0 deletions .github/workflows/pipeline-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: auto-deploy-develop
on:
push:
branches:
- develop
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Production Auto-Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/DeVouch-BE
git checkout develop
git checkout -- .
git pull
docker compose stop devouch squid-db
docker compose rm -v -f devouch squid-db
docker rmi -f $(docker images | grep 'devouch' | awk '{print $3}')
docker volume rm $(docker volume ls | grep 'db-data' | awk '{print $2}')
docker compose up -d --build
21 changes: 21 additions & 0 deletions .github/workflows/start-devouch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: start-devouch

on:
workflow_dispatch:

jobs:

start:
name: Start Devouch
runs-on: ubuntu-latest
steps:
- name: Start Devouch
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/DeVouch-BE
docker compose up -d --build
24 changes: 24 additions & 0 deletions .github/workflows/stop-devouch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: stop-devouch

on:
workflow_dispatch:

jobs:

stop:
name: Stop Devouch
runs-on: ubuntu-latest
steps:
- name: Stop Devouch
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/DeVouch-BE
docker compose stop devouch squid-db
docker compose rm -f -v devouch squid-db
docker rmi -f $(docker images | grep 'devouch' | awk '{print $3}')
docker volume rm $(docker volume ls | grep 'db-data' | awk '{print $2}')
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# IDE files
/.idea
/.vscode
.env
/.env
29 changes: 29 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Global Options
{
log global {
output file /usr/src/app/global.log
format json
level error
}
servers {
metrics
}
admin 0.0.0.0:2020
}

# ADMIN ROUTE ####
:2019 {
route {
@allowed {
path /*
remote_ip {$IP_WHITELIST}
}
reverse_proxy @allowed 127.0.0.1:2020
respond 403
}
}

# HTTP site block
{$GQL_URL} {
reverse_proxy devouch:4350
}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Node.js 20 image as a parent image
FROM node:20-alpine

# Set the working directory in the Docker container
WORKDIR /usr/src/app

# Install Python and build-essential (for C++ bindings)
RUN apk add --no-cache python3 py3-pip make g++

# Copy the package.json and package-lock.json for npm install
COPY package*.json ./

# Install any global dependencies
RUN npm install -g @subsquid/cli

# Install project dependencies
RUN npm ci

# Copy the rest of the application
COPY . .

# Build the project using the Squid CLI
RUN sqd build

# Expose the port the app runs on
EXPOSE 4350

# Command to run the application
CMD ["sqd", "run", "."]
8 changes: 4 additions & 4 deletions add-organisation.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const createOrganisationAddMigration =
require("./db/create-organisation-add-migration").default;

const ORGANISATION_NAME = "Trace"; // Replace with your own organisation name
const ORGANISATION_NAME = "Giveth Verification Team"; // Replace with your own organisation name
const SCHEMA_ID =
"0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722"; // Replace with your own schema id
const AUTHORIZED_ATTESTOR = "0xF23eA0b5F14afcbe532A1df273F7B233EBe41C78";
const COLOR = "#FF0000";
"0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"; // Replace with your own schema id
const AUTHORIZED_ATTESTOR = "0x826976d7C600d45FB8287CA1d7c76FC8eb732030";
const COLOR = "#7f64cb";

function main() {
createOrganisationAddMigration(
Expand Down
6 changes: 5 additions & 1 deletion db/create-organisation-add-migration.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const fs = require("fs");

// To make all add organisation migration run after the initial migration
const ADD_ORG_MIGRATION_OFFSET = 10000000000; // More than 317 years!

exports.default = function createOrganisationAddMigration(
organisationName,
schemaId,
authorizedAttestor,
color = null
) {
const timestamp = new Date().getTime();
const timestamp = new Date().getTime() + ADD_ORG_MIGRATION_OFFSET;
const fileName = `${timestamp}-Add${organisationName}.js`;
const className = `Add${organisationName.replace(/ /g, "")}${timestamp}`;

Expand Down
25 changes: 0 additions & 25 deletions db/migrations/1714572602788-AddTrace.js

This file was deleted.

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

23 changes: 23 additions & 0 deletions db/migrations/1725254645149-AddTrace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = class AddTrace1725254645149 {
name = "AddTrace1725254645149";

async up(db) {
// add organisation with name "Trace" and schema id "0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722"
await db.query(
`INSERT INTO "organisation" ("id", "name", "issuer", "color")
VALUES (
'0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722',
'Trace',
'0xf23ea0b5f14afcbe532a1df273f7b233ebe41c78',
'#ff0000'
)`
);
}

async down(db) {
// remove organisation with name "Trace" and schema id "0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722"
await db.query(
`DELETE FROM "organisation" WHERE "id" = '0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722'`
);
}
};
23 changes: 23 additions & 0 deletions db/migrations/1725344741698-AddGiveth Verification Team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = class AddGivethVerificationTeam1725344741698 {
name = "AddGivethVerificationTeam1725344741698";

async up(db) {
// add organisation with name "Giveth Verification Team" and schema id "0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"
await db.query(
`INSERT INTO "organisation" ("id", "name", "issuer", "color")
VALUES (
'0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404',
'Giveth Verification Team',
'0x826976d7c600d45fb8287ca1d7c76fc8eb732030',
'#7f64cb'
)`
);
}

async down(db) {
// remove organisation with name "Giveth Verification Team" and schema id "0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"
await db.query(
`DELETE FROM "organisation" WHERE "id" = '0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404'`
);
}
};
File renamed without changes.
12 changes: 12 additions & 0 deletions docker-compose-potgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"

services:
db:
image: postgres:15
environment:
POSTGRES_DB: squid
POSTGRES_PASSWORD: postgres
ports:
- "${DB_PORT}:5432"
# command: ["postgres", "-c", "log_statement=all"]
shm_size: 1gb
Loading

0 comments on commit 987e7ee

Please sign in to comment.