Skip to content

Commit

Permalink
Merge pull request #1960 from ten-protocol/initiate-bridge-deployment
Browse files Browse the repository at this point in the history
Initiate bridge deployment
  • Loading branch information
Jennievon authored Jun 20, 2024
2 parents 447ff48 + ff63945 commit 95f3515
Show file tree
Hide file tree
Showing 25 changed files with 21,816 additions and 363 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/manual-deploy-ten-bridge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Deploys Ten Bridge on Azure for Testnet
# Builds the Ten Bridge image, pushes the image to dockerhub and starts the Ten Bridge on Azure

name: "[M] Deploy Bridge Testnet"
run-name: "[M] Deploy Bridge Testnet ( ${{ github.event.inputs.testnet_type }} )"
on:
workflow_dispatch:
inputs:
testnet_type:
description: "Testnet Type"
required: true
default: "dev-testnet"
type: choice
options:
- "dev-testnet"
- "uat-testnet"
- "sepolia-testnet"

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- name: "Print GitHub variables"
# This is a useful record of what the environment variables were at the time the job ran, for debugging and reference
run: |
echo "GitHub Variables = ${{ toJSON(vars) }}"
- uses: actions/checkout@v3

- name: "Set up Docker"
uses: docker/setup-buildx-action@v1

- name: "Login to Azure docker registry"
uses: azure/docker-login@v1
with:
login-server: testnetobscuronet.azurecr.io
username: testnetobscuronet
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: "Login via Azure CLI"
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Build and Push Docker FE Image
run: |
DOCKER_BUILDKIT=1 docker build -t ${{ vars.DOCKER_BUILD_TAG_BRIDGE_FE }} -f ./contracts/src/bridge/frontend/Dockerfile .
docker push ${{ vars.DOCKER_BUILD_TAG_BRIDGE_FE }}
- name: "Deploy FE to Azure Container Instances"
uses: "azure/aci-deploy@v1"
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ github.event.inputs.testnet_type }}-ten-bridge
image: ${{ vars.DOCKER_BUILD_TAG_BRIDGE_FE }}
name: ${{ github.event.inputs.testnet_type }}-fe-ten-bridge
location: "uksouth"
restart-policy: "Never"
environment-variables: NEXT_PUBLIC_BRIDGE_API_HOST=https://${{ github.event.inputs.testnet_type }}-api.tenscan.io NEXT_PUBLIC_FE_VERSION=${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}
command-line: npm run start-prod
ports: "80"
cpu: 2
memory: 2
9 changes: 4 additions & 5 deletions contracts/src/bridge/L1/ObscuroBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";


// This is the Ethereum side of the Obscuro Bridge.
// End-users can interact with it to transfer ERC20 tokens and native eth to the Layer 2 Obscuro.
contract ObscuroBridge is
Expand All @@ -32,8 +31,8 @@ contract ObscuroBridge is

address remoteBridgeAddress;

function initialize(address messenger) public initializer() {
CrossChainEnabledObscuro.configure(messenger);
function initialize(address messenger) public initializer {
CrossChainEnabledObscuro.configure(messenger);
_grantRole(ADMIN_ROLE, msg.sender);
_grantRole(NATIVE_TOKEN_ROLE, address(0x0));
}
Expand Down Expand Up @@ -73,7 +72,7 @@ contract ObscuroBridge is
}

// This cross chain message is specialized and will result in automatic increase
// of balance on the other side.
// of balance on the other side.
// NOTE: If sent to a contract, there will be no fallback function executed.
// Instead after the contract receives it, one can relay the cross chain message to
// verify ETH deposit.
Expand All @@ -94,7 +93,7 @@ contract ObscuroBridge is
hasRole(ERC20_TOKEN_ROLE, asset),
"This address has not been given a type and is thus considered not whitelisted."
);

// ensures the token is correctly transferred to the contract - tx reverts on failure
SafeERC20.safeTransferFrom(
IERC20(asset),
Expand Down
3 changes: 3 additions & 0 deletions contracts/src/bridge/frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
36 changes: 36 additions & 0 deletions contracts/src/bridge/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
27 changes: 27 additions & 0 deletions contracts/src/bridge/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use an official Node.js 22 as a parent image
FROM node:22-alpine

WORKDIR /usr/src/app

# ARG for build-time variable
ARG API_HOST
ARG L1_BRIDGE
ARG L2_BRIDGE
ARG MESSAGE_BUS
ARG GOOGLE_ANALYTICS_ID

# ENV for URL to be used in the app
ENV NEXT_PUBLIC_BRIDGE_API_HOST=${API_HOST}
ENV NEXT_PUBLIC_BRIDGE_L1=${L1_BRIDGE}
ENV NEXT_PUBLIC_BRIDGE_L2=${L2_BRIDGE}
ENV NEXT_PUBLIC_BRIDGE_MESSAGE_BUS=${MESSAGE_BUS}
ENV NEXT_PUBLIC_BRIDGE_GOOGLE_ANALYTICS_ID=${GOOGLE_ANALYTICS_ID}

# Copy package.json and package-lock.json (or yarn.lock) into the container
COPY package*.json ./

RUN npm install
COPY . .
RUN npm run build
EXPOSE 80
CMD ["npm", "start"]
65 changes: 65 additions & 0 deletions contracts/src/bridge/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Bridge: Bridge for The Encryption Network (TEN)
<!-- ut essentially for us, he want to support the moving of assets (any) between Ethereum and TEN -->
<!-- Not yet, but we should support ETH, TEN, USDT, USDC at least to begin with -->

The Ten Bridge is a decentralized bridge that allows users to move assets between the Ethereum network and the TEN network. The bridge is a critical component of the TEN ecosystem, enabling users to move assets between the two networks seamlessly.

For more information on the TEN bridge, please refer to the [TEN Bridge Documentation](https://docs.ten.xyz/bridge).

## Folder Structure

```
📁 Bridge
├── 📁 pages - Typically used for Next.js pages. Each .tsx or .js file in this directory becomes a route in your application
├── 📁 public - This directory is used to serve static assets. Files inside this directory can be referenced in your code with a URL path
├── 📁 src - Main source code directory for this project
│ ├── 📁 components - Contains reusable React components used throughout the application
│ ├── 📁 hooks - Custom React hooks that can be shared and reused across components
│ ├── 📁 lib - Utility functions or modules that provide common functionalities across the application
│ ├── 📁 routes - Route-related logic or configuration can be placed in this directory
│ ├── 📁 services - Used for services that interact with external APIs or handle other data-related tasks
│ └── 📁 types - Type definitions (.d.ts files or TypeScript files) for TypeScript, describing the shape of data and objects used in the application
└── 📁 styles - Global styles, stylesheets, or styling-related configurations for this project
```

## Getting Started

1. **Clone the Repository:**
```bash
git clone https://github.com/ten-protocol/go-ten.git
cd go-ten/tools/tenscan/frontend
```

2. **Install Dependencies:**
```bash
npm install
```

3. **Run the Development Server:**
```bash
npm run dev
```

The application will be accessible at [http://localhost:3000](http://localhost:3000).

## Usage

- Visit the different sections of the explorer through the navigation links in the UI.
- Explore the different blocks, transactions, batches, resources, and personal data on the TEN.
- View the details of each batch by their hash.

## Built With

- [Next.js](https://nextjs.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Shadcn-UI](https://shadcn.com/)
- [TypeScript](https://www.typescriptlang.org/)


## Contributing

Contributions are welcome! Please follow our [contribution guidelines](/docs/_docs/community/contributions.md).

## License

This project is licensed under the [GNU Affero General Public License v3.0](/LICENSE).
16 changes: 16 additions & 0 deletions contracts/src/bridge/frontend/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "app/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/src/components",
"utils": "@/src/lib/utils"
}
}
6 changes: 6 additions & 0 deletions contracts/src/bridge/frontend/env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NEXT_PUBLIC_BRIDGE_API_HOST=

NEXT_PUBLIC_BRIDGE_L1=
NEXT_PUBLIC_BRIDGE_L2=
NEXT_PUBLIC_BRIDGE_MESSAGE_BUS=
NEXT_PUBLIC_BRIDGE_GOOGLE_ANALYTICS_ID=
9 changes: 9 additions & 0 deletions contracts/src/bridge/frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
unoptimized: true,
},
};

module.exports = nextConfig;
Loading

0 comments on commit 95f3515

Please sign in to comment.