Skip to content

Commit

Permalink
dockerize and add mountable config file
Browse files Browse the repository at this point in the history
  • Loading branch information
wanwiset25 committed Feb 16, 2025
1 parent b09a87e commit 0e5e9f2
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.next
package-lock.json
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and publish image
on:
push:
branches:
- master
- feature*
- fix*
tags:
- '*'
workflow_dispatch: #allow manual trigger to workflow

jobs:
build_and_push_image:
name: build and push image to registry
runs-on: ubuntu-latest
# environment: DockerHub
defaults:
run:
working-directory: deployment-generator
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Docker login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Determine Docker Image Name
id: image
run: |
if [[ "${{github.ref_name}}" == "master" ]]; then
echo "name=xinfinorg/subswap-frontend:latest" >> $GITHUB_OUTPUT
else
echo "name=xinfinorg/subswap-frontend:${{github.ref_name}}" >> $GITHUB_OUTPUT
fi
- name: Build and push image
run: |
docker build . --file docker/Dockerfile \
--build-arg SUBNET_BRANCH=${{ steps.commit.outputs.commit}} \
--build-arg IMAGE_NAME=${{ steps.image.outputs.name }} \
--tag ${{ steps.image.outputs.name }}
docker push ${{ steps.image.outputs.name }}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20

WORKDIR /app

COPY . /app

RUN yarn

ENTRYPOINT ["/bin/sh", "-c" , "yarn build && yarn start"]
56 changes: 35 additions & 21 deletions config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Chain } from "wagmi";
// import { existsSync, readFileSync } from 'fs';
import * as mountConfig from './subswap-frontend.config.json';

export { default as tokenABI } from "./abi/tokenABI.json";
export { default as lockABI } from "./abi/lockABI.json";
Expand All @@ -11,19 +13,24 @@ export { default as mintABI } from "./abi/mintABI.json";
// };

// testnet
const parentnet = {
chainid: 51,
url: "https://erpc.apothem.network/",
};
// const parentnet = {
// chainid: 51,
// url: "https://erpc.apothem.network/",
// };

//mainnet
// const parentnet = {
// chainid: 50,
// url: "https://rpc.xinfin.network",
// };

const parentnet = {
chainid: Number(mountConfig.parentnetChainId),
url: mountConfig.parentnetUrl
}

const subnet = {
chainid: 953,
chainid: Number(mountConfig.subnetChainId)
};

export const xdcParentNet: Chain = {
Expand All @@ -46,11 +53,6 @@ interface Applications {
locks: { [x: number]: string };
}

const applications: Applications = {
mints: { [parentnet.chainid]: "0x12f70272413eD247B1AEE55bf3e96f0f188b8749" },
locks: { [subnet.chainid]: "0x24b6A8dE05DD19eDE107606aE8BE252f9600Ead9" },
};

export interface CrossChainToken {
name: string;
subnetChainId: number;
Expand All @@ -62,17 +64,29 @@ export interface CrossChainToken {
mode: 1 | 2 | 3;
}

const crossChainTokens: CrossChainToken[] = [
{
name: "Token A",
subnetChainId: subnet.chainid,
parentnetChainId: parentnet.chainid,
subnetToken: "0x9ADb58BE55742cA8D32bB24aeE9A5eFe1419b916",
selectedToken: "",
logo: "/vercel.svg",
mode: 3,
},
];
const applications: Applications = {
mints: { [parentnet.chainid]: mountConfig['parentnetApp'] }, //parentnet subswap addr
locks: { [subnet.chainid]: mountConfig['subnetApp'] }, //subnet subswap addr
}


const crossChainTokens: CrossChainToken[] = []
for (let i = 0; i < mountConfig['tokens'].length; i++) {
const token = mountConfig['tokens'][i]
const mode = ('mode' in token) ? token['mode'] as CrossChainToken["mode"] : 3

crossChainTokens.push(
{
name: token['name'],
subnetChainId: subnet.chainid,
parentnetChainId: parentnet.chainid,
subnetToken: token['address'],
selectedToken: "",
logo: "/vercel.svg",
mode: mode
}
)
}

export const getTokens = (
subnetChainId: number | undefined,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"wagmi": "^1.3.9"
},
"devDependencies": {
"@types/node": "22.9.0",
"@types/react": "^18.2.47",
"@types/react-icons": "^3.0.0",
"typescript": "5.3.3"
Expand Down
14 changes: 14 additions & 0 deletions subswap-frontend.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parentnetUrl":"https://erpc.apothem.network/",
"parentnetChainId":"51",
"subnetUrl":"http://localhost:8545",
"subnetChainId":"999",
"subnetApp": "0x9777050a8402ac5958aA87631B15e98e26610EB5",
"parentnetApp": "0xC355520747171Bd75f505E8cd12f935944bD783b",
"tokens" : [
{
"name": "Token A",
"address": "0x103BAA273da5C2FEF2d1B8f839044A9bd07Bc1A1"
}
]
}

0 comments on commit 0e5e9f2

Please sign in to comment.