Skip to content

Commit

Permalink
Develop (#22)
Browse files Browse the repository at this point in the history
* draft

* add env.example

* add recoil provider

* remove recoil and add jotai

* feat: wallet connect integration

* fix: change the style of connected network button

* Feat: add network switcher (#2)

feat: add network switcher

* Feat: add deposit withdraw tab (#3)

feat: add deposit withdraw tab

* Victor/feature/deposit component (#4)

* feat: add deposit withdraw tab

* feat: add wallet connect button in bridge page

* feat: from and to network

* feat: to address component

* feat: get token balance and receive component

* fix: remove outline of token amount input

* remove thanos sdk module

* Feat: token select modal (#5)

feat: token select modal

* feat: add usdc and fetch token balance in real time

* Victor/feature/deposit tokens (#6)

* feat: add deposit confirm modal

* feat: add transaction confirm modal

* feat: deposit eth

* feat: deposit for native token

* feat: upgrade wagmi version to latest

* Victor/feature/withdraw tokens (#7)

* feat: withdraw initiate

* feat: add withdraw intermeidate steps

* feat: prove and finalize withdrawal

* prove and finalize tokens

* fix: erc token configuration and ui fix

* fix: withraw intermediate step ui

* upgrade thanos sdk version to 0.0.13

* fix: remove console log

* feat: add hover on token input component

* fix: change forground color

* Victor/feature/withdraw usdc (#9)

* feat: add usdc approval button

* fix signer issue

* upgrade sdk version and change l2 usdt address

* Fix ui issues (#11)

fix ui issues

* Victor/feature/docker (#12)

* add docker file

* update docker file

* add github action ci

* initiate cd yaml (#13)

* initiate cd yaml

* cd yaml file

* Victor/feature/cd (#14)

* initiate cd yaml

* cd yaml file

* fix docker hub username

* feat: disconnect wallet feature (#15)

* Victor/feature/account disconnect (#16)

* feat: disconnect wallet feature

* fix height of dropdowm menu

* Add next-runtime-env for runtime env loading (#17)

add next-runtime-env for runtime env loading

* Add proper UI/UX for non https rpc nodes (#18)

* add proper UI/UX for non https rpc nodes

* handle eslint issue

* Feat/warning popup for http rpc node config (#19)

* add proper UI/UX for non https rpc nodes

* handle eslint issue

* Feat/warning popup for http rpc node config (#20)

* add proper UI/UX for non https rpc nodes

* handle eslint issue

* update native token name

* Victor/feat/add readme (#21)

* add readme for local hosting

* add diagrams to readme
  • Loading branch information
vihsonic authored Jan 16, 2025
1 parent c37f196 commit 3dd6614
Show file tree
Hide file tree
Showing 122 changed files with 19,340 additions and 2,691 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
28 changes: 28 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
NEXT_PUBLIC_L1_CHAIN_NAME=Sepolia
NEXT_PUBLIC_L1_CHAIN_ID=11155111
NEXT_PUBLIC_L1_RPC=https://sepolia.infura.io/v3/e4b3b2781dd34bc4817a1221b8a3b50a
NEXT_PUBLIC_L1_NATIVE_CURRENCY_NAME=Sepolia Ether
NEXT_PUBLIC_L1_NATIVE_CURRENCY_SYMBOL=ETH
NEXT_PUBLIC_L1_NATIVE_CURRENCY_DECIMALS=18
NEXT_PUBLIC_L1_BLOCK_EXPLORER=https://sepolia.etherscan.io

NEXT_PUBLIC_L2_CHAIN_NAME="Thanos Sepolia"
NEXT_PUBLIC_L2_CHAIN_ID=111551119090
NEXT_PUBLIC_L2_RPC=https://rpc.thanos-sepolia.tokamak.network
NEXT_PUBLIC_L2_NATIVE_CURRENCY_NAME=TON
NEXT_PUBLIC_L2_NATIVE_CURRENCY_SYMBOL=TON
NEXT_PUBLIC_L2_NATIVE_CURRENCY_DECIMALS=18
NEXT_PUBLIC_L2_BLOCK_EXPLORER=https://explorer.thanos-sepolia.tokamak.network

NEXT_PUBLIC_NATIVE_TOKEN_L1_ADDRESS=0xa30fe40285b8f5c0457dbc3b7c8a280373c40044
NEXT_PUBLIC_L1_USDC_ADDRESS=0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238
NEXT_PUBLIC_L1_USDT_ADDRESS=0x42d3b260c761cD5da022dB56Fe2F89c4A909b04A
NEXT_PUBLIC_L2_USDT_ADDRESS=0xF5559bf8241AC3f8CC067C7BaD7Ec3eec176DB1b

NEXT_PUBLIC_STANDARD_BRIDGE_ADDRESS=0x757EC5b8F81eDdfC31F305F3325Ac6Abf4A63a5D
NEXT_PUBLIC_ADDRESS_MANAGER_ADDRESS=0xca074de2a95EE6ea37003585E8679f8f215Ea04c
NEXT_PUBLIC_L1_CROSS_DOMAIN_MESSENGER_ADDRESS=0xd054Bc768aAC07Dd0BaA2856a2fFb68F495E4CC2
NEXT_PUBLIC_OPTIMISM_PORTAL_ADDRESS=0x2fbD30Fcd1c4573b0288E706Be56B5c0d2DfcAF6
NEXT_PUBLIC_L2_OUTPUT_ORACLE_ADDRESS=0xC0885eEc313e31a917DFd5d6Bf33565826B93A3F
NEXT_PUBLIC_L1_USDC_BRIDGE_ADDRESS=0x7dD2196722FBe83197820BF30e1c152e4FBa0a6A
NEXT_PUBLIC_DISPUTE_GAME_FACTORY_ADDRESS=0x524c885A976c13497900A04257605cd231Ab0026
12 changes: 10 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
"extends": [
"next/core-web-vitals",
"typescript"
],
"rules": {
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-require-imports": "off"
}
}
29 changes: 29 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Push docker image to docker hub

on:
pull_request:
types: [closed]
branches:
- main

jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER_NAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_HUB_ORG_NAME }}/trh-op-bridge-app:latest
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Docker Image CI

on:
pull_request:
branches: ["main", "develop"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag trh-op-bridge-app:latest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yarn-debug.log*
yarn-error.log*

# env files (can opt-in for committing if needed)
.env*
.env

# vercel
.vercel
Expand Down
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"configurations": [
{
"name": "Docker Node.js Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"platform": "node"
}
]
}
39 changes: 39 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "node",
"dockerBuild": {
"dockerfile": "${workspaceFolder}/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": [
"docker-build"
],
"platform": "node"
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build"
],
"dockerRun": {
"env": {
"DEBUG": "*",
"NODE_ENV": "development"
}
},
"node": {
"enableDebugging": true
}
}
]
}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

FROM node:18-alpine AS builder

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build


FROM node:18-alpine AS production

WORKDIR /app

COPY --from=builder /app/ ./

EXPOSE 3000

CMD ["npm", "run", "start"]
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,76 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
# Thanos bridge

## Getting Started
This is a DApp which interacts with the Thanos chain where the users can bridge their assets to from Layer 1 (Ethereum or Sepolia) to the Thanos chain which is a Layer 2 rollup that can be deployed on Tokamak Rollup Hub.

First, run the development server:
## Features

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
- Deposit assets from Layer 1 to the Thanos chain
- Withdraw assets from the Thanos chain to Layer 1
- Tokens supported: ETH, L2 Native Token, USDT, USDC
- After the withdrawal initiated, the user get a transaction detail downloaded so the Tx Hash can be used for prove and finalize process.

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
## Tech stacks used

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
- [Next.js v14.2.11](https://nextjs.org/docs/14/app/building-your-application)
- [TypeScript](https://www.typescriptlang.org/docs/)
- [Chakra UI ^3.2.1](https://www.chakra-ui.com/docs/get-started/installation)
- [Wagmi ^2.13.3](https://wagmi.sh/react/getting-started)
- [Tokamak Thanos SDK ^0.0.14](https://www.npmjs.com/package/@tokamak-network/thanos-sdk)
- [Jotai ^2.10.3](https://jotai.org/docs)

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Local Hosting

## Learn More
### Prerequisites

To learn more about Next.js, take a look at the following resources:
1. Node.js v18.17.0+
2. npm v10+

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
### Steps

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
1. Clone the repository
2. Copy `.env.example` to `.env` and fill in the values
3. Run `yarn install`
4. Run `yarn dev`
5. Open [http://localhost:3000](http://localhost:3000) in your browser

## Deploy on Vercel
### Environment Variables

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
| Variable Name | Description |
| ----------------------------------------------- | ----------------------------------------------------------- |
| `NEXT_PUBLIC_L1_CHAIN_NAME` | The name of the L1 chain (e.g. "Sepolia") |
| `NEXT_PUBLIC_L1_CHAIN_ID` | The chain ID of the L1 chain (e.g. 11155111) |
| `NEXT_PUBLIC_L1_RPC` | The RPC URL of the L1 chain |
| `NEXT_PUBLIC_L1_NATIVE_CURRENCY_NAME` | The name of the L1 native currency (e.g. "Sepolia Ether") |
| `NEXT_PUBLIC_L1_NATIVE_CURRENCY_SYMBOL` | The symbol of the L1 native currency (e.g. "ETH") |
| `NEXT_PUBLIC_L1_NATIVE_CURRENCY_DECIMALS` | The number of decimals for the L1 native currency (e.g. 18) |
| `NEXT_PUBLIC_L1_BLOCK_EXPLORER` | The block explorer URL for the L1 chain |
| `NEXT_PUBLIC_L2_CHAIN_NAME` | The name of the L2 chain (e.g. "Thanos Sep") |
| `NEXT_PUBLIC_L2_CHAIN_ID` | The chain ID of the L2 chain (e.g. 1237345) |
| `NEXT_PUBLIC_L2_RPC` | The RPC URL of the L2 chain |
| `NEXT_PUBLIC_L2_NATIVE_CURRENCY_NAME` | The name of the L2 native currency (e.g. "TON") |
| `NEXT_PUBLIC_L2_NATIVE_CURRENCY_SYMBOL` | The symbol of the L2 native currency (e.g. "TON") |
| `NEXT_PUBLIC_L2_NATIVE_CURRENCY_DECIMALS` | The number of decimals for the L2 native currency (e.g. 18) |
| `NEXT_PUBLIC_L2_BLOCK_EXPLORER` | The block explorer URL for the L2 chain |
| `NEXT_PUBLIC_NATIVE_TOKEN_L1_ADDRESS` | The L1 address of the native token |
| `NEXT_PUBLIC_L1_USDC_ADDRESS` | The L1 address of USDC |
| `NEXT_PUBLIC_L1_USDT_ADDRESS` | The L1 address of USDT |
| `NEXT_PUBLIC_L2_USDT_ADDRESS` | The L2 address of USDT |
| `NEXT_PUBLIC_STANDARD_BRIDGE_ADDRESS` | The address of the standard bridge contract |
| `NEXT_PUBLIC_ADDRESS_MANAGER_ADDRESS` | The address of the address manager contract |
| `NEXT_PUBLIC_L1_CROSS_DOMAIN_MESSENGER_ADDRESS` | The address of the L1 cross domain messenger contract |
| `NEXT_PUBLIC_OPTIMISM_PORTAL_ADDRESS` | The address of the optimism portal contract |
| `NEXT_PUBLIC_L2_OUTPUT_ORACLE_ADDRESS` | The address of the L2 output oracle contract |
| `NEXT_PUBLIC_L1_USDC_BRIDGE_ADDRESS` | The address of the L1 USDC bridge contract |
| `NEXT_PUBLIC_DISPUTE_GAME_FACTORY_ADDRESS` | The address of the dispute game factory contract |

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
## High level architecture

![alt text](./src/assets/readme/thanos-bridge-arch.png)

## Code Diagram

[Code Diagram](./thanos-bridge.codediagram)

## Deployment

Once the PR is merged to the `main` branch, the docker image is being pushed to [docker hub](https://hub.docker.com/repository/docker/tokamaknetwork/trh-op-bridge-app).
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}

module.exports = nextConfig
7 changes: 0 additions & 7 deletions next.config.ts

This file was deleted.

Loading

0 comments on commit 3dd6614

Please sign in to comment.