Skip to content

Commit 8d56beb

Browse files
committed
Refactor backend codes.
1 parent 7e3e681 commit 8d56beb

Some content is hidden

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

94 files changed

+3922
-816
lines changed

backend/.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Application configuration variables
2+
PORT= # Port to run the application on
3+
RPC_PORT= # Port to run the RPC server on
4+
5+
SNAPSHOT_RPC= # RPC URL for the snapshot node
6+
MYSQL_HOST= # Host for the MySQL database
7+
MYSQL_USER= # Username for the MySQL database
8+
MYSQL_PASSWORD= # Password for the MySQL database
9+
MYSQL_DATABASE= # Database name for the MySQL database
10+
11+
POWERVOTING_CONTRACT= # Contract address for the PowerVoting contract
12+
ORACLE_POWERS_CONTRACT= # Contract address for the Oracle Powers contract
13+
SYNC_EVENT_START_HEIGHT= # Start height for the sync event
14+
ORACLE_CONTRACT= # Contract address for the Oracle contract
15+
FIP_CONTRACT= # Contract address for the FIP contract
16+
FIP_INIT_EDITOR= # Address of the FIP init editor on deploy the FIP Contract
17+
18+
POWERVOTING_API_PATH= # API path for the PowerVoting contract
19+
ORACLE_API_PATH= # API path for the Oracle contract
20+
FIP_ABI_PATH= # ABI path for the FIP contract
21+
ORACLE_POWERS_ABI_PATH= # ABI path for the Oracle Powers contract
22+
23+
CHAIN_ID=314159 # Chain ID for the network
24+
CHAIN_NAME=FileCoin-Calibration # Chain name for the network
25+
CHAIN_RPC_NODE=http://192.168.11.139:1235/rpc/v1 # RPC URL for the chain node

powervoting-backend/Dockerfile renamed to backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ COPY --from=backend-builder /build/app .
2323
COPY --from=backend-builder /build/configuration.yaml .
2424
COPY --from=backend-builder /build/abi/power-voting.json ./
2525
COPY --from=backend-builder /build/abi/oracle.json ./
26+
COPY --from=backend-builder /build/abi/power-voting-fip.json ./
27+
COPY --from=backend-builder /build/abi/oracle-powers.json ./
28+
2629

2730
EXPOSE 18007
2831

backend/Dockerfile.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM golang:alpine AS backend-builder
2+
3+
ENV GO111MODULE=on \
4+
GOPROXY=https://goproxy.cn,direct \
5+
CGO_ENABLED=0 \
6+
GOOS=linux \
7+
GOARCH=amd64
8+
9+
WORKDIR /build
10+
11+
COPY powervoting-backend/go.mod powervoting-backend/go.sum ./
12+
RUN go mod tidy
13+
14+
COPY powervoting-backend/. .
15+
16+
RUN go build -o app .
17+
18+
FROM alpine:latest
19+
20+
WORKDIR /dist
21+
22+
COPY --from=backend-builder /build/app .
23+
COPY --from=backend-builder /build/configuration-backend.yaml .
24+
25+
COPY --from=backend-builder /build/abi/power-voting.json ./
26+
COPY --from=backend-builder /build/abi/power-voting-fip.json ./
27+
# Copy oracle abi to instance
28+
COPY --from=backend-builder /build/abi/oracle-powers.json ./
29+
COPY --from=backend-builder /build/abi/oracle.json ./
30+
31+
CMD ["/dist/app"]
File renamed without changes.
File renamed without changes.
File renamed without changes.

backend/abi/oracle-powers.json

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[
2+
{
3+
"inputs": [],
4+
"name": "ActorNotFound",
5+
"type": "error"
6+
},
7+
{
8+
"inputs": [],
9+
"name": "FailToCallActor",
10+
"type": "error"
11+
},
12+
{
13+
"inputs": [],
14+
"name": "FailToCallActor",
15+
"type": "error"
16+
},
17+
{
18+
"inputs": [
19+
{
20+
"internalType": "CommonTypes.FilActorId",
21+
"name": "actorId",
22+
"type": "uint64"
23+
}
24+
],
25+
"name": "InvalidActorID",
26+
"type": "error"
27+
},
28+
{
29+
"inputs": [
30+
{
31+
"internalType": "uint64",
32+
"name": "",
33+
"type": "uint64"
34+
}
35+
],
36+
"name": "InvalidCodec",
37+
"type": "error"
38+
},
39+
{
40+
"inputs": [],
41+
"name": "InvalidResponseLength",
42+
"type": "error"
43+
},
44+
{
45+
"inputs": [
46+
{
47+
"internalType": "uint256",
48+
"name": "balance",
49+
"type": "uint256"
50+
},
51+
{
52+
"internalType": "uint256",
53+
"name": "value",
54+
"type": "uint256"
55+
}
56+
],
57+
"name": "NotEnoughBalance",
58+
"type": "error"
59+
},
60+
{
61+
"inputs": [
62+
{
63+
"internalType": "uint64",
64+
"name": "minerID",
65+
"type": "uint64"
66+
}
67+
],
68+
"name": "getOwner",
69+
"outputs": [
70+
{
71+
"internalType": "uint64",
72+
"name": "",
73+
"type": "uint64"
74+
}
75+
],
76+
"stateMutability": "view",
77+
"type": "function"
78+
},
79+
{
80+
"inputs": [
81+
{
82+
"internalType": "address",
83+
"name": "addr",
84+
"type": "address"
85+
}
86+
],
87+
"name": "resolveEthAddress",
88+
"outputs": [
89+
{
90+
"internalType": "uint64",
91+
"name": "",
92+
"type": "uint64"
93+
}
94+
],
95+
"stateMutability": "view",
96+
"type": "function"
97+
}
98+
]

backend/abi/oracle.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[
2+
{
3+
"anonymous": false,
4+
"inputs": [
5+
{
6+
"indexed": false,
7+
"internalType": "address",
8+
"name": "voterAddress",
9+
"type": "address"
10+
},
11+
{
12+
"indexed": false,
13+
"internalType": "string",
14+
"name": "gistId",
15+
"type": "string"
16+
}
17+
],
18+
"name": "UpdateGistIdsEvent",
19+
"type": "event"
20+
},
21+
{
22+
"anonymous": false,
23+
"inputs": [
24+
{
25+
"indexed": false,
26+
"internalType": "address",
27+
"name": "voterAddress",
28+
"type": "address"
29+
},
30+
{
31+
"indexed": false,
32+
"internalType": "uint64[]",
33+
"name": "minerIds",
34+
"type": "uint64[]"
35+
}
36+
],
37+
"name": "UpdateMinerIdsEvent",
38+
"type": "event"
39+
}
40+
]

backend/abi/power-voting-fip.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[
2+
{
3+
"anonymous": false,
4+
"inputs": [
5+
{
6+
"components": [
7+
{
8+
"internalType": "uint256",
9+
"name": "proposalId",
10+
"type": "uint256"
11+
},
12+
{
13+
"internalType": "int8",
14+
"name": "proposalType",
15+
"type": "int8"
16+
},
17+
{
18+
"internalType": "address",
19+
"name": "creator",
20+
"type": "address"
21+
},
22+
{
23+
"internalType": "string",
24+
"name": "candidateInfo",
25+
"type": "string"
26+
},
27+
{
28+
"internalType": "address",
29+
"name": "candidateAddress",
30+
"type": "address"
31+
}
32+
],
33+
"indexed": false,
34+
"internalType": "struct FipEditorProposalCreateInfo",
35+
"name": "proposal",
36+
"type": "tuple"
37+
}
38+
],
39+
"name": "FipEditorProposalCreateEvent",
40+
"type": "event"
41+
},
42+
{
43+
"anonymous": false,
44+
"inputs": [
45+
{
46+
"indexed": false,
47+
"internalType": "uint256",
48+
"name": "proposalId",
49+
"type": "uint256"
50+
}
51+
],
52+
"name": "FipEditorProposalPassedEvent",
53+
"type": "event"
54+
},
55+
{
56+
"anonymous": false,
57+
"inputs": [
58+
{
59+
"components": [
60+
{
61+
"internalType": "address",
62+
"name": "voter",
63+
"type": "address"
64+
},
65+
{
66+
"internalType": "uint256",
67+
"name": "proposalId",
68+
"type": "uint256"
69+
}
70+
],
71+
"indexed": false,
72+
"internalType": "struct FipEditorProposalVoteInfo",
73+
"name": "voteInfo",
74+
"type": "tuple"
75+
}
76+
],
77+
"name": "FipEditorProposalVoteEvent",
78+
"type": "event"
79+
}
80+
]
File renamed without changes.

0 commit comments

Comments
 (0)