-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Fix]: Update rpc for arbitrium sepolia * [update]: added try catch block to route handler * [update]: added try catch block to route handler * [deploy]: Preping for wbtc bridge * [deploy]: Preping for wbtc bridge * Update push-prod.yml * change * Update push.yml * [Feature]: implemented WBTC on the frontend (#55) --------- Co-authored-by: stephenson080 <[email protected]> Co-authored-by: Stephen Udeh <[email protected]>
- Loading branch information
1 parent
131a7d1
commit 64c9277
Showing
149 changed files
with
94,900 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
node_modules/ | ||
dist/ | ||
|
||
.gitignore | ||
.git/ | ||
.env | ||
.env.local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PROD=false | ||
PRIVATE_KEY="7eb433edd85f1774c4a15f460e822071729b6177bdb2418f67e3d9e50c773d2a" | ||
VITE_BACKEND_LINK="https://gotbit-xend-multitoken-backend-dev.dev.gotbit.app" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
.env | ||
node_modules/ | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
stages: | ||
- test | ||
- build | ||
- deploy | ||
|
||
# variables: | ||
# SKIP_COMPONENTS_TEST: 'true' | ||
# SKIP_BUILD_TEST: 'true' | ||
# SKIP_TYPECHECK_TEST: 'true' | ||
|
||
include: | ||
- project: '$DEVOPS_PROJECT_PATH' | ||
ref: 'main' | ||
file: 'gitlabci/build/backend/.gitlab-ci.yml' | ||
|
||
- project: '$DEVOPS_PROJECT_PATH' | ||
ref: 'main' | ||
file: 'clients/build/backend/aws/.gitlab-ci.yml' | ||
|
||
- project: '$DEVOPS_PROJECT_PATH' | ||
ref: 'main' | ||
file: 'gitlabci/deploy/backend/.gitlab-ci.yml' | ||
|
||
- project: '$DEVOPS_PROJECT_PATH' | ||
ref: 'main' | ||
file: 'gitlabci/test/backend/.gitlab-ci.yml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"semi": false, | ||
"printWidth": 90, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 90, | ||
"tabWidth": 4 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:16 | ||
|
||
ARG PROD | ||
ARG PRIVATE_KEY | ||
COPY package.json ./ | ||
COPY yarn.lock ./ | ||
|
||
RUN yarn | ||
|
||
COPY . . | ||
RUN yarn build | ||
|
||
|
||
EXPOSE 3000 | ||
CMD yarn serve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Asset Chain Bridge backend for BTC | ||
|
||
## Description | ||
|
||
Bridge is a decentralized application that consists of front-end, back-end, and smart contracts on every blockchain network used in the Bridge. | ||
|
||
## Table of Contents | ||
|
||
- [Getting Started](#getting-started) | ||
- [Project Structure](#project-structure) | ||
- [Contracts](#contracts) | ||
- [Confirmations blocks](#confirmations-blocks) | ||
- [Endpoints](#endpoints) | ||
- [Backend structure](#backend-structure) | ||
- [SecurityBackend structure](#security) | ||
|
||
## Getting Started | ||
|
||
Recommended Node version is 16.20.0. | ||
|
||
Generate `.env` file | ||
|
||
```bash | ||
$ cp .env.example .env | ||
``` | ||
|
||
Add .env file to the project root. | ||
|
||
To add the private key of a relayer account, assign the following variable and add `PROD` variable (`true` to setup mainnet or `false` to setup testnet) | ||
|
||
``` | ||
PRIVATE_KEY= | ||
PROD= | ||
``` | ||
|
||
```bash | ||
$ yarn | ||
$ yarn build | ||
$ yarn serve | ||
``` | ||
|
||
## Project Structure | ||
|
||
This a typescript backend with `express`. | ||
|
||
This backend does not use the database and does not listen to events | ||
|
||
Endpoint `/transactions` receiving the user's address from the frontend at the moment of request runs through all used networks and gets the user's transactions using the `getUserTransactions()` function on the contract. After that, the backend finds pairs among them, which indicates that the transaction is labeled and the remaining transactions are not picked up on the destined networks. Having received the final list of transactions, the backend gives them to the frontend | ||
|
||
Endpoint `/sign` receiving as input the parameters | ||
`fromChain: string`, | ||
`fromUser: string`, | ||
`index: string`, | ||
`toBridgeAssistAddress: string`, | ||
`fromBridgeAddress: string` | ||
finds the required transaction on the source network, checks that the required number of confirmation blocks has passed and if the check has passed, signs it and returns it to the user. | ||
|
||
### Contracts | ||
|
||
Smart contracts abis are found in `./src/contracts/contracts.json`. | ||
|
||
### Confirmations blocks | ||
|
||
List of amount confirmations block are found in `./src/confirmations.json`. | ||
You can change them by replace `0` to anoter number for the corresponding chainId. | ||
|
||
For example if you set `"1": 15` - after send to Ethereum mainnet you need to wait `15` blocks before `claim` | ||
|
||
### Endpoints | ||
|
||
/transactions - get all transactions by user | ||
params: | ||
user - address | ||
|
||
/sign - get signature of selected transaction | ||
params: | ||
fromChain - source chain (evm.1) | ||
fromUser - sender address | ||
index - transaction index | ||
toBridgeAssistAddress - Destination chain Bridge Assist Contract address | ||
fromBridgeAddress - Source chain Bridge Assist Contract address | ||
|
||
/health - check server health | ||
|
||
### Backend structure | ||
|
||
This is a backend written in typesctipt using gotbit tools template. | ||
|
||
You have 2 environment variables that must be defined in the .env file. | ||
|
||
All networks, contracts and rpc supported by the project are defined in the ./src/gotbit-config.ts file. | ||
|
||
There are 2 sets of rpc "universalRpc" and "extraRpc". | ||
The first set is defined in src/gotbit-tools/node/rpc.ts | ||
The second is defined in src/gotbit-tools/node/utils/node.ts | ||
You can change them as you wish | ||
|
||
All endpoints are located in the src/routes folder | ||
|
||
There is also a file confirmations.json in which the number of confirmations blocks for each chainId is defined. | ||
You can increase the number of confirmations blocks to prevent frontrunner attacks. | ||
Increasing the number of blocks will allow the user to pick up the money on the receiving network only after it has passed. | ||
|
||
|
||
You can see more details about gotbit-tools in /frontend/src/gotbit-tools/README.md | ||
|
||
### Security | ||
|
||
Do not show the private key used to sign transactions to anyone. | ||
If an intruder gets this key, he can sign a fake transaction with it and withdraw all the money from your bridge. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:16 | ||
|
||
COPY package.json ./ | ||
COPY yarn.lock ./ | ||
|
||
RUN yarn | ||
|
||
COPY . . | ||
RUN yarn build | ||
|
||
|
||
EXPOSE 3000 | ||
CMD yarn serve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"name": "kyc-app", | ||
"scripts": { | ||
"dev": "yarn build && concurrently 'tsc -w' 'DEBUG=true node-dev --respawn dist/app.js'", | ||
"win": "rd /s /q dist && tsc -p .", | ||
"build": "rm -rf dist && tsc -p .", | ||
"serve": "node dist/app.js", | ||
"\n# TESTING SCRIPTS:": "", | ||
"type": "tsc -p . --noEmit", | ||
"test": "TEST=true jest", | ||
"coverage": "yarn test --coverage", | ||
"test:gotbit-tools": "yarn test --dir src/gotbit-tools", | ||
"test:build": "yarn build", | ||
"test:full": "yarn type && yarn test && yarn test:build", | ||
"\n# GOTBIT-TOOLS SCRIPTS:": "", | ||
"update": "cd src && npx gotbit-tools@latest install node -d ./src", | ||
"contracts": "yarn contracts:sync && yarn contracts:typings", | ||
"contracts:sync": "SCRIPT=./src/gotbit-tools/scripts/shell/import-contracts.sh yarn script", | ||
"contracts:typings": "node ./src/gotbit-tools/scripts/typings.js", | ||
"\n# UTILS SCRIPTS:": "", | ||
"script": "chmod +x $SCRIPT && $SCRIPT" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"moduleNameMapper": { | ||
"@/(.*)": "<rootDir>/src/$1" | ||
}, | ||
"testMatch": [ | ||
"<rootDir>/src/__tests__/**/*.test.ts" | ||
], | ||
"testTimeout": 600000 | ||
}, | ||
"engines": { | ||
"node": ">=16.0.0" | ||
}, | ||
"_moduleAliases": { | ||
"@": "dist/" | ||
}, | ||
"version": "1.0.0", | ||
"main": "src/app.ts", | ||
"author": "kotsmile", | ||
"license": "MIT", | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"body-parser": "^1.20.0", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.0.0", | ||
"ethers": "^5.6.6", | ||
"ethers-multicall": "^0.2.3", | ||
"express": "^4.18.1", | ||
"express-automatic-routes": "^1.1.0", | ||
"helmet": "^5.0.2", | ||
"module-alias": "^2.2.2", | ||
"moment": "^2.29.3", | ||
"morgan": "^1.10.0" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.3", | ||
"@types/cors": "^2.8.12", | ||
"@types/express": "^4.17.13", | ||
"@types/jest": "^29.0.1", | ||
"@types/mocha": "^9.1.1", | ||
"@types/morgan": "^1.9.3", | ||
"@types/node": "^17.0.31", | ||
"@types/supertest": "^2.0.12", | ||
"c8": "^7.11.3", | ||
"chai": "^4.3.6", | ||
"concurrently": "^7.1.0", | ||
"jest": "^29.0.3", | ||
"mocha": "^10.0.0", | ||
"node-dev": "^7.4.3", | ||
"supertest": "^6.2.4", | ||
"ts-jest": "^29.0.0", | ||
"typescript": "^4.6.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'backend-wbtc', // Application name | ||
script: 'dist/app.js', // Script to be run | ||
instances: 1, // Number of instances to be started | ||
autorestart: true, // Automatically restart crashed application | ||
watch: false, // Watch files for changes | ||
max_memory_restart: '1G', // Restart the application if it reaches this memory usage | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'mocha' | ||
import { expect } from 'chai' | ||
|
||
import app from '@/app' | ||
import request from 'supertest' | ||
|
||
describe('health route', () => { | ||
it('should', async () => { | ||
const response = await request(app).get('/health') | ||
expect(response.text).eq('Server is Healthy') | ||
}) | ||
}) |
Oops, something went wrong.