Skip to content

Commit

Permalink
fix: small bugs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Argeare5 committed Dec 16, 2024
1 parent 5a7f289 commit a0050b3
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
NEXT_PUBLIC_DEPLOY_FOR_IPFS=false
NEXT_PUBLIC_TERMS_AND_CONDITIONS_VISIBLE=false
NEXT_PUBLIC_WC_PROJECT_ID=your_wc_project_id#https://docs.walletconnect.com/2.0/cloud/relay
NEXT_PUBLIC_RPC_MAINNET=""
NEXT_PUBLIC_RPC_POLYGON=""
NEXT_PUBLIC_RPC_AVALANCHE=""

RPC_MAINNET=
RPC_AVALANCHE=
Expand Down
File renamed without changes
File renamed without changes
4 changes: 3 additions & 1 deletion src/components/ProposalsList/FiltersPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Box, useTheme } from '@mui/system';
import { useRouter } from 'next/navigation';
import React, { useState } from 'react';
import { mainnet } from 'viem/chains';

import { appConfig } from '../../configs/appConfig';
import { proposalStatusesForFilter } from '../../helpers/statuses';
import { texts } from '../../helpers/texts/texts';
import { useStore } from '../../providers/ZustandStoreProvider';
Expand Down Expand Up @@ -171,7 +173,7 @@ export function FiltersPanel() {
statuses={proposalStatusesForFilter}
selectedStatus={filters.state}
setSelectedStatus={setFilteredStateLocal}
disabled={false} // TODO
disabled={appConfig.govCoreChainId !== mainnet.id}
/>
</Box>
</TopPanelContainer>
Expand Down
6 changes: 4 additions & 2 deletions src/components/ProposalsList/FinishedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export function FinishedItem({ data }: { data: ProposalOnTheList }) {
: theme.palette.$text,
typography: 'h2',
}}>
{proposalDetails[data.proposalId]?.metadata?.title ??
data.title}
{data.title !== `Proposal ${data.proposalId}`
? data.title
: (proposalDetails[data.proposalId]?.metadata?.title ??
data.title)}
</Box>
</Box>

Expand Down
4 changes: 2 additions & 2 deletions src/components/Web3/creationFee/CreationFeesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ export function CreationFeesModal({
<img
width="100%"
height="auto"
src="/src/assets/DarkNoFees.svg"
src="/DarkNoFees.svg"
alt={texts.creationFee.noData}
/>
) : (
// eslint-disable-next-line @next/next/no-img-element
<img
width="100%"
height="auto"
src="/src/assets/LightNoFees.svg"
src="/LightNoFees.svg"
alt="You haven't created any proposals yet"
/>
)}
Expand Down
6 changes: 5 additions & 1 deletion src/configs/chains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { getChains } from '../utils/getChains';
import { getInitialRpcUrls } from '../utils/getInitialRpcUrls';

export const initialRpcUrls = getInitialRpcUrls({});
export const initialRpcUrls = getInitialRpcUrls({
mainnetRPC: process.env.NEXT_PUBLIC_RPC_MAINNET,
polygonRPC: process.env.NEXT_PUBLIC_RPC_POLYGON,
avalancheRPC: process.env.NEXT_PUBLIC_RPC_AVALANCHE,
});
export const CHAINS = getChains({ initialRpcUrls });
6 changes: 6 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ export const env = createEnv({
NEXT_PUBLIC_DEPLOY_FOR_IPFS: z.string().or(z.undefined()),
NEXT_PUBLIC_TERMS_AND_CONDITIONS_VISIBLE: z.string().or(z.undefined()),
NEXT_PUBLIC_WC_PROJECT_ID: z.string().or(z.undefined()),
NEXT_PUBLIC_RPC_MAINNET: z.string().or(z.undefined()),
NEXT_PUBLIC_RPC_POLYGON: z.string().or(z.undefined()),
NEXT_PUBLIC_RPC_AVALANCHE: z.string().or(z.undefined()),
},
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_RPC_MAINNET: process.env.NEXT_PUBLIC_RPC_MAINNET,
NEXT_PUBLIC_RPC_POLYGON: process.env.NEXT_PUBLIC_RPC_POLYGON,
NEXT_PUBLIC_RPC_AVALANCHE: process.env.NEXT_PUBLIC_RPC_AVALANCHE,
RPC_MAINNET: process.env.RPC_MAINNET,
RPC_POLYGON: process.env.RPC_POLYGON,
RPC_AVALANCHE: process.env.RPC_AVALANCHE,
Expand Down
4 changes: 2 additions & 2 deletions src/old/web3/components/creationFee/CreationFeesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ export function CreationFeesModal({
<img
width="100%"
height="auto"
src="/src/assets/DarkNoFees.svg"
src="/DarkNoFees.svg"
alt={texts.creationFee.noData}
/>
) : (
// eslint-disable-next-line @next/next/no-img-element
<img
width="100%"
height="auto"
src="/src/assets/LightNoFees.svg"
src="/LightNoFees.svg"
alt="You haven't created any proposals yet"
/>
)}
Expand Down
35 changes: 20 additions & 15 deletions src/requests/fetchVoters.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import { formatUnits } from 'viem';
import { mainnet } from 'viem/chains';

import { appConfig } from '../configs/appConfig';
import { DECIMALS, INITIAL_API_URL } from '../configs/configs';
import { VoterAPI } from '../types';
import { GetVotersRPC, getVotersRPC } from './utils/getVotersRPC';

export async function fetchVoters({ input }: { input: GetVotersRPC }) {
try {
const url = `${INITIAL_API_URL}/voting/${input.proposalId}/allVoters/`;
const dataRaw = await fetch(url);
const data = (await dataRaw.json()) as VoterAPI[];
return data.map((vote) => {
return {
proposalId: input.proposalId,
address: vote.voter,
support: vote.support,
votingPower: +formatUnits(BigInt(vote.votingPower), DECIMALS),
transactionHash: vote.txHash,
blockNumber: input.startBlockNumber,
chainId: input.votingChainId,
ensName: undefined,
};
});
if (appConfig.govCoreChainId === mainnet.id) {
const url = `${INITIAL_API_URL}/voting/${input.proposalId}/allVoters/`;
const dataRaw = await fetch(url);
const data = (await dataRaw.json()) as VoterAPI[];
return data.map((vote) => {
return {
proposalId: input.proposalId,
address: vote.voter,
support: vote.support,
votingPower: +formatUnits(BigInt(vote.votingPower), DECIMALS),
transactionHash: vote.txHash,
blockNumber: input.startBlockNumber,
chainId: input.votingChainId,
ensName: undefined,
};
});
}
throw new Error('This chain id for gov core not supported by API');
} catch (e) {
console.error('Error getting voters list from API, using RPC fallback', e);
return await getVotersRPC({ ...input });
Expand Down
5 changes: 4 additions & 1 deletion src/store/representationsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ export const createRepresentationsSlice: StoreSlice<

await get().executeTx({
body: () => {
return updateRepresentatives({ data: formattedData });
return updateRepresentatives({
wagmiConfig: get().wagmiConfig,
data: formattedData,
});
},
params: {
type: TxType.representations,
Expand Down
14 changes: 9 additions & 5 deletions src/store/transactionsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
RepresentationFormData,
VotingDataByUser,
} from '../types';
import { ICreationFeesSlice } from './creationFeesSlice';
import { IDelegationSlice } from './delegationSlice';
import { IProposalSlice } from './proposalSlice';
import { IRepresentationsSlice } from './representationsSlice';
Expand Down Expand Up @@ -300,7 +301,8 @@ export const createTransactionsSlice: StoreSlice<
IRpcSwitcherSlice &
IProposalSlice &
IRepresentationsSlice &
IDelegationSlice
IDelegationSlice &
ICreationFeesSlice
> = (set, get) => ({
vote: async ({
votingChainId,
Expand Down Expand Up @@ -338,6 +340,7 @@ export const createTransactionsSlice: StoreSlice<
body: () => {
return gelato
? voteBySignature({
wagmiConfig: get().wagmiConfig,
votingChainId,
proposalId,
support,
Expand All @@ -350,6 +353,7 @@ export const createTransactionsSlice: StoreSlice<
proofOfRepresentation: proofOfRepresentative,
})
: vote({
wagmiConfig: get().wagmiConfig,
votingChainId,
proposalId,
support,
Expand Down Expand Up @@ -382,6 +386,7 @@ export const createTransactionsSlice: StoreSlice<
body: () => {
return gelato
? voteBySignature({
wagmiConfig: get().wagmiConfig,
votingChainId,
proposalId,
support,
Expand All @@ -392,6 +397,7 @@ export const createTransactionsSlice: StoreSlice<
proofs,
})
: vote({
wagmiConfig: get().wagmiConfig,
votingChainId,
proposalId,
support,
Expand Down Expand Up @@ -688,10 +694,8 @@ export const createTransactionsSlice: StoreSlice<
await get().getProposalDetails(data.payload.proposalId);
break;
case TxType.claimFees:
// await get().updateCreationFeesDataByCreator(
// data.payload.creator,
// data.payload.proposalIds,
// );
await get().getCreationFeesData(data.payload.creator);
await get().updateCreationFeesDataByCreator(data.payload.creator);
break;
}
},
Expand Down

1 comment on commit a0050b3

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.