From a0050b358ffd9c561d0d363fb3239cb79e88ac44 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 16 Dec 2024 11:38:48 +0200 Subject: [PATCH] fix: small bugs fixes --- .env.example | 3 ++ {src/assets => public}/DarkNoFees.svg | 0 {src/assets => public}/LightNoFees.svg | 0 src/components/ProposalsList/FiltersPanel.tsx | 4 ++- src/components/ProposalsList/FinishedItem.tsx | 6 ++-- .../Web3/creationFee/CreationFeesModal.tsx | 4 +-- src/configs/chains.ts | 6 +++- src/env.js | 6 ++++ .../creationFee/CreationFeesModal.tsx | 4 +-- src/requests/fetchVoters.ts | 35 +++++++++++-------- src/store/representationsSlice.ts | 5 ++- src/store/transactionsSlice.ts | 14 +++++--- 12 files changed, 58 insertions(+), 29 deletions(-) rename {src/assets => public}/DarkNoFees.svg (100%) rename {src/assets => public}/LightNoFees.svg (100%) diff --git a/.env.example b/.env.example index 49aefe0c..d07d2aca 100644 --- a/.env.example +++ b/.env.example @@ -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= diff --git a/src/assets/DarkNoFees.svg b/public/DarkNoFees.svg similarity index 100% rename from src/assets/DarkNoFees.svg rename to public/DarkNoFees.svg diff --git a/src/assets/LightNoFees.svg b/public/LightNoFees.svg similarity index 100% rename from src/assets/LightNoFees.svg rename to public/LightNoFees.svg diff --git a/src/components/ProposalsList/FiltersPanel.tsx b/src/components/ProposalsList/FiltersPanel.tsx index 00e08631..3570de2b 100644 --- a/src/components/ProposalsList/FiltersPanel.tsx +++ b/src/components/ProposalsList/FiltersPanel.tsx @@ -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'; @@ -171,7 +173,7 @@ export function FiltersPanel() { statuses={proposalStatusesForFilter} selectedStatus={filters.state} setSelectedStatus={setFilteredStateLocal} - disabled={false} // TODO + disabled={appConfig.govCoreChainId !== mainnet.id} /> diff --git a/src/components/ProposalsList/FinishedItem.tsx b/src/components/ProposalsList/FinishedItem.tsx index 101e3be9..30f5a694 100644 --- a/src/components/ProposalsList/FinishedItem.tsx +++ b/src/components/ProposalsList/FinishedItem.tsx @@ -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)} diff --git a/src/components/Web3/creationFee/CreationFeesModal.tsx b/src/components/Web3/creationFee/CreationFeesModal.tsx index 84d7b0cc..fce188eb 100644 --- a/src/components/Web3/creationFee/CreationFeesModal.tsx +++ b/src/components/Web3/creationFee/CreationFeesModal.tsx @@ -255,7 +255,7 @@ export function CreationFeesModal({ {texts.creationFee.noData} ) : ( @@ -263,7 +263,7 @@ export function CreationFeesModal({ You haven't created any proposals yet )} diff --git a/src/configs/chains.ts b/src/configs/chains.ts index 2c1b2aaa..d04c6791 100644 --- a/src/configs/chains.ts +++ b/src/configs/chains.ts @@ -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 }); diff --git a/src/env.js b/src/env.js index fe0b64ac..d620915a 100644 --- a/src/env.js +++ b/src/env.js @@ -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, diff --git a/src/old/web3/components/creationFee/CreationFeesModal.tsx b/src/old/web3/components/creationFee/CreationFeesModal.tsx index 8361b6d5..8224287b 100644 --- a/src/old/web3/components/creationFee/CreationFeesModal.tsx +++ b/src/old/web3/components/creationFee/CreationFeesModal.tsx @@ -245,7 +245,7 @@ export function CreationFeesModal({ {texts.creationFee.noData} ) : ( @@ -253,7 +253,7 @@ export function CreationFeesModal({ You haven't created any proposals yet )} diff --git a/src/requests/fetchVoters.ts b/src/requests/fetchVoters.ts index 8edef204..8c5dc9ec 100644 --- a/src/requests/fetchVoters.ts +++ b/src/requests/fetchVoters.ts @@ -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 }); diff --git a/src/store/representationsSlice.ts b/src/store/representationsSlice.ts index 15c856eb..18f90f34 100644 --- a/src/store/representationsSlice.ts +++ b/src/store/representationsSlice.ts @@ -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, diff --git a/src/store/transactionsSlice.ts b/src/store/transactionsSlice.ts index 7260a9fb..5e345db9 100644 --- a/src/store/transactionsSlice.ts +++ b/src/store/transactionsSlice.ts @@ -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'; @@ -300,7 +301,8 @@ export const createTransactionsSlice: StoreSlice< IRpcSwitcherSlice & IProposalSlice & IRepresentationsSlice & - IDelegationSlice + IDelegationSlice & + ICreationFeesSlice > = (set, get) => ({ vote: async ({ votingChainId, @@ -338,6 +340,7 @@ export const createTransactionsSlice: StoreSlice< body: () => { return gelato ? voteBySignature({ + wagmiConfig: get().wagmiConfig, votingChainId, proposalId, support, @@ -350,6 +353,7 @@ export const createTransactionsSlice: StoreSlice< proofOfRepresentation: proofOfRepresentative, }) : vote({ + wagmiConfig: get().wagmiConfig, votingChainId, proposalId, support, @@ -382,6 +386,7 @@ export const createTransactionsSlice: StoreSlice< body: () => { return gelato ? voteBySignature({ + wagmiConfig: get().wagmiConfig, votingChainId, proposalId, support, @@ -392,6 +397,7 @@ export const createTransactionsSlice: StoreSlice< proofs, }) : vote({ + wagmiConfig: get().wagmiConfig, votingChainId, proposalId, support, @@ -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; } },