Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fx: multi language bug #161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
363 changes: 59 additions & 304 deletions power-voting/src/App.tsx

Large diffs are not rendered by default.

448 changes: 280 additions & 168 deletions power-voting/src/common/abi/oracle.json

Large diffs are not rendered by default.

457 changes: 232 additions & 225 deletions power-voting/src/common/abi/power-voting.json

Large diffs are not rendered by default.

34 changes: 9 additions & 25 deletions power-voting/src/common/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { filecoin, filecoinCalibration } from 'wagmi/chains';

export const mainnetChainId = filecoin.id;
export const calibrationChainId = filecoinCalibration.id;
export const powerVotingMainNetContractAddress = process.env.POWER_VOTING_MAINNET_CONTRACT_ADDRESS || '';
export const oracleMainNetContractAddress = process.env.ORACLE_MAINNET_CONTRACT_ADDRESS || '';
export const oraclePowerMainNetContractAddress = process.env.ORACLE_POWER_MAINNET_CONTRACT_ADDRESS || '';
Expand All @@ -25,8 +29,8 @@ export const uploadApi = '/api/w3storage/upload';
export const proposalHistoryApi = '/api/proposal/history';
export const proposalDraftAddApi = '/api/proposal/draft/add';
export const proposalDraftGetApi = '/api/proposal/draft/get';

export const worldTimeApi = 'https://worldtimeapi.org/api/timezone/Etc/UTC';
export const blockHeightGetApi = '/api/filecoin/height';
export const votePowerGetApi = '/api/proposal/draft/get';
export const IN_PROGRESS_STATUS = 2;
export const COMPLETED_STATUS = 4;
export const PENDING_STATUS = 1;
Expand Down Expand Up @@ -288,7 +292,7 @@ var (

2.1 Go to https://vote.storswift.io.

2.2 Click UCAN Delegates to cancel authorization. The website will monitor whether the Eth account has UCAN authorization or not. The action will cancel the authorization if it does.
2.2 Click UCAN Delegates to cancel authorization. The website will monitor whether the Eth account has UCAN authorization or not. The action will cancel the authorization if it does.

<p>
<img src="/images/img_1.png" />
Expand Down Expand Up @@ -497,33 +501,13 @@ export const NOT_FIP_EDITOR_MSG = 'content.fipCreateProposals';
export const NO_FIP_EDITOR_APPROVE_ADDRESS_MSG = 'content.inputAddress';
export const NO_FIP_EDITOR_REVOKE_ADDRESS_MSG = 'content.selectAddress';
export const NO_ENOUGH_FIP_EDITOR_REVOKE_ADDRESS_MSG = 'content.twoFIPRevoke';
export const FIP_ALREADY_EXECUTE_MSG = "content.activePproposal"
export const FIP_ALREADY_EXECUTE_MSG = "content.activeProposal"
export const FIP_APPROVE_SELF_MSG = "content.noPropose"
export const FIP_APPROVE_ALREADY_MSG = "content.addressDditor"
export const FIP_APPROVE_ALREADY_MSG = "content.addressEditor"
export const HAVE_APPROVED_MSG = 'content.alreadyApproved';
export const HAVE_REVOKED_MSG = 'content.alreadyRevoked';
export const CAN_NOT_REVOKE_YOURSELF_MSG = 'content.revokeYourself';
export const SAVE_DRAFT_SUCCESS = "content.saveSuccess"
export const SAVE_DRAFT_TOO_LARGE = "content.savedDescriptionCharacters"
export const SAVE_DRAFT_FAIL = "content.saveFail"
export const UPLOAD_DATA_FAIL_MSG = "content.saveDataFail"

// Converts hexadecimal to a string
export const hexToString = (hex: any) => {
if(!hex){
return '';
}
let str = '';
if (hex.substring(1, 3) === '0x') {
str = hex.substring(3)
} else {
str = hex;
}
// Split a hexadecimal string by two characters
const pairs = str.match(/[\dA-Fa-f]{2}/g);
if (pairs == null) {
return '';
}
// Converts split hexadecimal numbers to characters and concatenates them
return pairs.map((pair: any) => String.fromCharCode(parseInt(pair, 16))).join('').replace(/[^\x20-\x7E]/g, '').trim();
}
12 changes: 12 additions & 0 deletions power-voting/src/common/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ export const useCheckFipEditorAddress = (chainId: number, address: `0x${string}`
};
}

export const useVoterAddress = (chainId: number) => {
const { data, isSuccess: voterAddressSuccess } = useReadContract({
address: getContractAddress(chainId, 'oracle'),
abi: oracleAbi,
functionName: 'getVoterAddresses',
});
return {
voterAddress: data,
voterAddressSuccess
} as any;
}

export const useLatestId = (chainId: number, enabled: boolean) => {
const { data: latestId, isLoading: getLatestIdLoading, refetch } = useReadContract({
address: getContractAddress(chainId, 'powerVoting'),
Expand Down
3 changes: 1 addition & 2 deletions power-voting/src/common/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { create } from 'zustand';

interface StoringCidState {
storingCid: string[];
}
Expand All @@ -22,7 +21,7 @@ export const useVotingList = create(set => ({
setVotingList: (newData: any) => set({ votingData: newData }),
}));

export const usePropsalStatus = create(set => ({
export const useProposalStatus = create(set => ({
status: '',
setStatusList: (status: 0) => set({ status: status }),
}));
Expand Down
7 changes: 3 additions & 4 deletions power-voting/src/components/CreateTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { QuestionCircleOutlined } from '@ant-design/icons';
import type { ReactNode } from 'react';
import React from 'react';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import { FILECOIN_AUTHORIZE_DOC, FILECOIN_DEAUTHORIZE_DOC, GITHUB_AUTHORIZE_DOC, GITHUB_DEAUTHORIZE_DOC } from "../common/consts";

export default function Table({ title = '', link = {} as { type: string, action: string, href: string }, list = [] as { name: string, hide?: boolean, comp: ReactNode, width?: number, desc?: ReactNode, }[], subTitle = <div /> }) {
const navigate = useNavigate();
Expand All @@ -25,9 +24,9 @@ export default function Table({ title = '', link = {} as { type: string, action:
const handleJump = () => {
let doc = '';
if (type === 'filecoin') {
doc = action === 'authorize' ? FILECOIN_AUTHORIZE_DOC : FILECOIN_DEAUTHORIZE_DOC;
doc = action === 'authorize' ? 'filecion_authorize_doc' : 'filecion_deauthorize_doc';
} else {
doc = action === 'authorize' ? GITHUB_AUTHORIZE_DOC : GITHUB_DEAUTHORIZE_DOC;
doc = action === 'authorize' ? 'github_authorize_doc' : 'github_deauthorize_doc';
}
navigate(href, {
state: {
Expand Down
Loading
Loading