Skip to content

Commit c75a703

Browse files
committed
Refactor frontend codes.
1 parent 518a067 commit c75a703

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2997
-3125
lines changed
File renamed without changes.

power-voting/.gitignore renamed to frontend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dist.zip
1717

1818
# env
1919
.env
20+
.env.example
2021

2122
# misc
2223
.eslintcache
File renamed without changes.
File renamed without changes.

frontend/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 使用 Node.js 镜像作为构建环境
2+
FROM node:22 as build-stage
3+
4+
# 设置工作目录
5+
WORKDIR /app
6+
7+
# 复制 package.json 和 package-lock.json
8+
COPY power-voting/package*.json ./
9+
10+
# 安装依赖
11+
RUN yarn install
12+
13+
# 复制项目文件
14+
COPY power-voting .
15+
16+
# 构建项目
17+
RUN yarn build
18+
19+
# 使用 Nginx 镜像作为生产环境
20+
FROM nginx:alpine
21+
22+
# 将构建产物复制到 Nginx 的静态文件目录
23+
COPY --from=build-stage /app/dist /usr/share/nginx/html
24+
25+
# 复制自定义的 Nginx 配置文件
26+
COPY power-voting/nginx.conf /etc/nginx/conf.d/default.conf
27+
28+
# 暴露 80 端口
29+
EXPOSE 80
30+
31+
# 启动 Nginx
32+
CMD ["nginx", "-g", "daemon off;"]

power-voting/Dockerfile renamed to frontend/Dockerfile.github

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN yarn build
1515

1616
FROM nginx:alpine
1717

18-
COPY --from=build /app/dist /voting/dev/dist
18+
COPY --from=build /app/dist /voting/dev/distya
1919

2020
COPY nginx.conf /etc/nginx/conf.d/default.conf
2121

File renamed without changes.

power-voting/README.md renamed to frontend/README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
## 1. Overview
44

5-
Power Voting dApp utilizes timelock based on smart contract technology to achieve fair and private voting. Before the voting deadline, no one’s voting results will be seen by others, and the voting process will not be disturbed by other participant’s voting results. After the voting deadline, anyone can count the votes in a decentralized manner, and the results of the counting will executed and stored by smart contract and will not be manipulated by any centralized organization or individual.
6-
7-
Power Voting dApp aims to become the infrastructure of DAO governance.
5+
Power Voting dApp is implemented according to [Filecoin Community Voting Specs](https://docs.google.com/document/d/13910NE-O3mUQ6rztt6f3xe7hwW_aS-xaPW_zHuTpBW4/edit#heading=h.4kbcnjlru68f). It utilizes Drand Timelock technology to achieve fair and private voting. It supports voting for multiple roles including Token Holders, Storage Providers, Clients and Developers. Different roles are given different voting weights according to their contributions or token holdings. Power Voting dApp allows different roles with different voting weights to cast the votes and then unify voting power.
86

97
## 2. Problem
108

119
In the community voting process governed by DAO, since the voting data of other community members can be seen before the vote counting time, the community members will be affected by the existing voting data before voting, and some members will even take advantage of a large number of voting rights in their hands to vote at the end of the voting process to make the voting results are reversed, resulting in unfair voting.
1210

13-
In the centralized voting process, since the vote counting power is in the hands of the centralized organization, it will cause problems such as vote fraud and black box operation of vote counting, resulting in the voting results being manipulated by others, which cannot truly reflect the wishes of the community.
11+
In the centralized voting process, since the vote counting power is in the hands of the centralized organization, it will cause problems such as vote fraud and black box operation of vote counting, resulting in the voting results being manipulated by others, which cannot truly reflect the views of the community.
1412

1513
## 3. Solution
1614

@@ -26,7 +24,7 @@ When creating a proposal, the creator will enter a voting expiration time, and P
2624

2725
## 5. Voting Power Snapshot
2826

29-
Power Oracle will request raw data from FileCoin, GitHub and other data sources to calculate role identity and voting power and save them into Power Oracle contracts. SP and Client respectively invoke the `PowerAPI.minerRawPower(filActorld)` and `DataCapAPI.balance(filActorld)` interfaces to retrieve power. Power Oracle contracts will store 60 days history of voting power. When users vote, only the percentage is recorded, not the actual voting power. During the vote counting process, a random weight will be selected from the 60 days history and multiplied by the percentage to calculate the vote.
27+
Power Oracle will request raw data from FileCoin, GitHub and other data sources to identify roles and calculate their voting weights and save them into Power Oracle contracts. SP and Client respectively invoke the `PowerAPI.minerRawPower(filActorld)` and `DataCapAPI.balance(filActorld)` interfaces to retrieve power. Power Oracle contracts will store 60-day history of voting power. When users vote, only the percentage is recorded, not the actual voting power. During the vote counting process, a random weight will be selected from the 60 days history and multiplied by the percentage to calculate the vote.
3028

3129
## 6. Power Voting Flowchart
3230

@@ -41,9 +39,9 @@ Power Oracle will request raw data from FileCoin, GitHub and other data sources
4139
![](img/ucan1.png)
4240
![](img/ucan2.png)
4341

44-
## 9. Install
42+
## 9. Deploy
4543

46-
#### 1.Environment and Development Tools
44+
#### 1. Environment and Development Tools
4745

4846
1.Node.js 14 or later installed
4947

@@ -55,15 +53,15 @@ Power Oracle will request raw data from FileCoin, GitHub and other data sources
5553

5654
<img src="./img/git.png" style="zoom:50%;" alt="" />
5755

58-
#### 2.Download Source Code
56+
#### 2. Download Source Code
5957

6058
Download the source code with the following command:
6159

6260
```
6361
git clone https://github.com/black-domain/power-voting.git
6462
```
6563

66-
#### 3.Install Dependencies
64+
#### 3. Install Dependencies
6765

6866
Install dependencies with the following command:
6967

@@ -76,7 +74,7 @@ After yarn, you will get a 'node_modules' folder in the root directory.
7674

7775
<img src="img/node_modules.png" style="zoom:50%;" alt="" />
7876

79-
#### 4.Update Keys in .env.example
77+
#### 4. Update Keys in .env.example
8078

8179
Deploying PowerVoting and Oracle contract on Filecoin main network and replace the following address in ‘/.env.example’
8280

@@ -96,7 +94,7 @@ Create wallet connect project id by https://www.rainbowkit.com/docs/migration-gu
9694

9795
Set 'WALLET_CONNECT_ID' in ‘/.env.example’
9896

99-
#### 6.Build And Package
97+
#### 6. Build And Package
10098

10199
Build with the following command:
102100

@@ -108,13 +106,11 @@ After building, you will get a 'dist' folder in the root directory.
108106

109107
<img src="img/dist.png" style="zoom:50%;" alt="" />
110108

111-
#### 7.Deployment
109+
#### 7. Deployment
112110

113111
To deploy the 'dist ' folder generated after building your front-end project, you can follow these steps:
114112

115113
1. **Upload the dist folder to the server**: Upload the `dist` folder to your server. You can use FTP tools, SSH, or other methods to transfer the files to a specific directory on your server.
116114
2. **Configure the Web Server**: Ensure that your web server (such as Nginx, Apache, etc.) is properly configured, and you know where to serve static files from. Add a new site or virtual host in the configuration file and set the document root to point to the uploaded `dist` folder.
117115
3. **Start the Web Server**: Start or restart your web server to apply the new configuration.
118-
4. **Access the Website**: Open your browser and enter your domain name or server IP address. You should be able to see your deployed front-end application.
119-
120-
116+
4. **Access the Website**: Open your browser and enter your domain name or server IP address. You should be able to see your deployed front-end application.

power-voting/build.sh renamed to frontend/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ echo "project: $IMAGE_NAME, port: $PORT"
2727
git pull origin main
2828
)
2929

30-
docker build -t $IMAGE_NAME .
30+
docker build -t $IMAGE_NAME -f Dockerfile.github .
3131

3232
if docker ps -a --format '{{.Names}}' | grep -wq "$IMAGE_NAME"; then
3333
echo "Stopping container: $IMAGE_NAME..."
File renamed without changes.

0 commit comments

Comments
 (0)