{isReceivedRequestToBeDelegate && (
-
Account {delegator} wants to delegate voting to your address.
+
+ Account {delegator} wants to delegate voting to your address.
+
+ )}
+ {isSentRequestToBeDelegate && (
+
+ You requested {delegate} to be your delegated voting address.
+
)}
- {isSentRequestToBeDelegate &&
You requested {delegate} to be your delegated voting address.}
Waiting for approval |{" "}
-
+
View Transaction
@@ -68,13 +106,22 @@ export function PendingRequests({
{isReceivedRequestToBeDelegate && (
- acceptReceivedRequestToBeDelegate(delegator)} />
+ acceptReceivedRequestToBeDelegate(delegator)}
+ />
)}
{isReceivedRequestToBeDelegate && (
- ignoreReceivedRequestToBeDelegate(delegator)} />
+ ignoreReceivedRequestToBeDelegate(delegator)}
+ />
)}
{isSentRequestToBeDelegate && (
- cancelSentRequestToBeDelegate()} />
+ cancelSentRequestToBeDelegate()}
+ />
)}
diff --git a/components/pages/WalletSettings/WalletSettings.tsx b/components/pages/WalletSettings/WalletSettings.tsx
index bb6e5d0b..641d5b60 100644
--- a/components/pages/WalletSettings/WalletSettings.tsx
+++ b/components/pages/WalletSettings/WalletSettings.tsx
@@ -1,4 +1,10 @@
-import { Banner, Layout, LoadingSpinner, PageInnerWrapper, PageOuterWrapper } from "components";
+import {
+ Banner,
+ Layout,
+ LoadingSpinner,
+ PageInnerWrapper,
+ PageOuterWrapper,
+} from "components";
import { useDelegationContext } from "hooks";
import styled from "styled-components";
import { Wallets } from "./Wallets";
diff --git a/components/pages/WalletSettings/Wallets.tsx b/components/pages/WalletSettings/Wallets.tsx
index 5c84a6d1..55acec79 100644
--- a/components/pages/WalletSettings/Wallets.tsx
+++ b/components/pages/WalletSettings/Wallets.tsx
@@ -15,8 +15,12 @@ export function Wallets() {
{delegationStatus === "no-delegation" &&
}
{delegationStatus === "delegator" &&
}
{delegationStatus === "delegate" &&
}
- {delegationStatus === "delegator-pending" &&
}
- {delegationStatus === "delegate-pending" &&
}
+ {delegationStatus === "delegator-pending" && (
+
+ )}
+ {delegationStatus === "delegate-pending" && (
+
+ )}
);
}
diff --git a/components/pages/WalletSettings/styles.tsx b/components/pages/WalletSettings/styles.tsx
index d1baa696..297e6202 100644
--- a/components/pages/WalletSettings/styles.tsx
+++ b/components/pages/WalletSettings/styles.tsx
@@ -49,10 +49,38 @@ export const AddressWrapper = styled.div`
const barButtonWidth = 160;
const barButtonHeight = 40;
-export const BarButtonPrimary = ({ label, onClick }: { label: ReactNode; onClick: () => void }) => {
- return
;
+export const BarButtonPrimary = ({
+ label,
+ onClick,
+}: {
+ label: ReactNode;
+ onClick: () => void;
+}) => {
+ return (
+
+ );
};
-export const BarButtonSecondary = ({ label, onClick }: { label: ReactNode; onClick: () => void }) => {
- return
;
+export const BarButtonSecondary = ({
+ label,
+ onClick,
+}: {
+ label: ReactNode;
+ onClick: () => void;
+}) => {
+ return (
+
+ );
};
diff --git a/constant/index.ts b/constant/index.ts
new file mode 100644
index 00000000..32c84d54
--- /dev/null
+++ b/constant/index.ts
@@ -0,0 +1,71 @@
+export { graphEndpoint } from "./query/graphEndpoint";
+export {
+ activeVotesKey,
+ balancesQueryKeys,
+ committedVotesForDelegatorKey,
+ committedVotesKey,
+ contentfulDataKey,
+ decryptedVotesKey,
+ delegateToStakerKey,
+ delegatorSetEventForDelegateKey,
+ delegatorSetEventsForDelegatorKey,
+ encryptedVotesKey,
+ hasActiveVotesKey,
+ ignoredRequestToBeDelegateAddressesKey,
+ outstandingRewardsKey,
+ pastVotesKey,
+ receivedRequestsToBeDelegateKey,
+ revealedVotesKey,
+ sentRequestsToBeDelegateKey,
+ stakerDetailsKey,
+ tokenAllowanceKey,
+ unstakeCoolDownKey,
+ unstakedBalanceKey,
+ upcomingVotesKey,
+ userDataKey,
+ voterFromDelegateKey,
+ voteTransactionHashesKey,
+ votingNotUserDependentQueryKeys,
+ votingQueryKeys,
+ votingUserDependentQueryKeys,
+} from "./query/queryKeys";
+export {
+ black,
+ blackOpacity25,
+ blackOpacity50,
+ blackOpacity60,
+ blackOpacity75,
+ green,
+ grey100,
+ grey50,
+ grey500,
+ grey800,
+ loadingSkeletonOpacity10,
+ loadingSkeletonOpacity100,
+ red100,
+ red500,
+ red500Opacity5,
+ red600,
+ white,
+ whiteOpacity10,
+} from "./styles/colors";
+export { bannerHeight, desktopMaxWidth, desktopPanelWidth, headerHeight } from "./styles/containers";
+export {
+ headerLg,
+ headerMd,
+ headerSm,
+ headerXl,
+ headerXs,
+ textFine,
+ textLg,
+ textMd,
+ textSm,
+ textXs,
+} from "./styles/fonts";
+export { shadow1, shadow2, shadow3 } from "./styles/shadows";
+export { discordLink } from "./voting/discordLink";
+export { earlyRequestMagicNumber } from "./voting/earlyRequestMagicNumber";
+export { numPhases, phaseLength, phaseLengthMilliseconds, roundLength } from "./voting/voteTiming";
+export { votingContractAddress, votingTokenContractAddress } from "./web3/addresses";
+export { goerliDeployBlock } from "./web3/deployBlocks";
+export { signingMessage } from "./web3/signingMessage";
diff --git a/constant/query/graphEndpoint.ts b/constant/query/graphEndpoint.ts
new file mode 100644
index 00000000..26ac8dab
--- /dev/null
+++ b/constant/query/graphEndpoint.ts
@@ -0,0 +1 @@
+export const graphEndpoint = process.env.NEXT_PUBLIC_GRAPH_ENDPOINT ?? "";
diff --git a/constants/queryKeys.ts b/constant/query/queryKeys.ts
similarity index 100%
rename from constants/queryKeys.ts
rename to constant/query/queryKeys.ts
diff --git a/constants/colors.ts b/constant/styles/colors.ts
similarity index 100%
rename from constants/colors.ts
rename to constant/styles/colors.ts
diff --git a/constants/containers.ts b/constant/styles/containers.ts
similarity index 100%
rename from constants/containers.ts
rename to constant/styles/containers.ts
diff --git a/constants/fonts.ts b/constant/styles/fonts.ts
similarity index 100%
rename from constants/fonts.ts
rename to constant/styles/fonts.ts
diff --git a/constants/shadows.ts b/constant/styles/shadows.ts
similarity index 100%
rename from constants/shadows.ts
rename to constant/styles/shadows.ts
diff --git a/constants/discordLink.ts b/constant/voting/discordLink.ts
similarity index 100%
rename from constants/discordLink.ts
rename to constant/voting/discordLink.ts
diff --git a/constant/voting/earlyRequestMagicNumber.ts b/constant/voting/earlyRequestMagicNumber.ts
new file mode 100644
index 00000000..ca5e09d8
--- /dev/null
+++ b/constant/voting/earlyRequestMagicNumber.ts
@@ -0,0 +1,2 @@
+export const earlyRequestMagicNumber =
+ "-57896044618658097711785492504343953926634992332820282019728.792003956564819968";
diff --git a/constants/voteTiming.ts b/constant/voting/voteTiming.ts
similarity index 100%
rename from constants/voteTiming.ts
rename to constant/voting/voteTiming.ts
diff --git a/constants/addresses.ts b/constant/web3/addresses.ts
similarity index 100%
rename from constants/addresses.ts
rename to constant/web3/addresses.ts
diff --git a/constants/deployBlocks.ts b/constant/web3/deployBlocks.ts
similarity index 100%
rename from constants/deployBlocks.ts
rename to constant/web3/deployBlocks.ts
diff --git a/constant/web3/signingMessage.ts b/constant/web3/signingMessage.ts
new file mode 100644
index 00000000..dd4183e6
--- /dev/null
+++ b/constant/web3/signingMessage.ts
@@ -0,0 +1 @@
+export const signingMessage = process.env.NEXT_PUBLIC_SIGNING_MESSAGE ?? "Login to UMA Voter dApp";
diff --git a/constants/earlyRequestMagicNumber.ts b/constants/earlyRequestMagicNumber.ts
deleted file mode 100644
index 2dd85578..00000000
--- a/constants/earlyRequestMagicNumber.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-const earlyRequestMagicNumber = "-57896044618658097711785492504343953926634992332820282019728.792003956564819968";
-
-export default earlyRequestMagicNumber;
diff --git a/constants/graphEndpoint.ts b/constants/graphEndpoint.ts
deleted file mode 100644
index 5a30c4bb..00000000
--- a/constants/graphEndpoint.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-const graphEndpoint = process.env.NEXT_PUBLIC_GRAPH_ENDPOINT ?? "";
-
-export default graphEndpoint;
diff --git a/constants/signingMessage.ts b/constants/signingMessage.ts
deleted file mode 100644
index ada99b97..00000000
--- a/constants/signingMessage.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-const signingMessage = process.env.NEXT_PUBLIC_SIGNING_MESSAGE ?? "Login to UMA Voter dApp";
-
-export default signingMessage;
diff --git a/contexts/ContractsContext.tsx b/contexts/ContractsContext.tsx
index 8dfe6d92..7da844f9 100644
--- a/contexts/ContractsContext.tsx
+++ b/contexts/ContractsContext.tsx
@@ -1,6 +1,9 @@
import { VotingTokenEthers, VotingV2Ethers } from "@uma/contracts-frontend";
import { createContext, ReactNode, useState } from "react";
-import { createVotingContractInstance, createVotingTokenContractInstance } from "web3";
+import {
+ createVotingContractInstance,
+ createVotingTokenContractInstance,
+} from "web3";
export interface ContractsContextState {
voting: VotingV2Ethers;
@@ -19,14 +22,19 @@ export const defaultContractContextState = {
setVotingToken: () => null,
};
-export const ContractsContext = createContext
(defaultContractContextState);
+export const ContractsContext = createContext(
+ defaultContractContextState
+);
export function ContractsProvider({ children }: { children: ReactNode }) {
const [voting, setVoting] = useState(defaultVoting);
- const [votingToken, setVotingToken] = useState(defaultVotingToken);
+ const [votingToken, setVotingToken] =
+ useState(defaultVotingToken);
return (
-
+
{children}
);
diff --git a/contexts/DelegationContext.tsx b/contexts/DelegationContext.tsx
index 4a1a25d4..3b03ced3 100644
--- a/contexts/DelegationContext.tsx
+++ b/contexts/DelegationContext.tsx
@@ -56,7 +56,9 @@ export const defaultDelegationContextState: DelegationContextState = {
getDelegationDataFetching: () => false,
};
-export const DelegationContext = createContext(defaultDelegationContextState);
+export const DelegationContext = createContext(
+ defaultDelegationContextState
+);
export function DelegationProvider({ children }: { children: ReactNode }) {
const {
@@ -94,17 +96,28 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
isLoading: ignoredRequestToBeDelegateAddressesLoading,
isFetching: ignoredRequestToBeDelegateAddressesFetching,
} = useIgnoredRequestToBeDelegateAddresses();
- const { ignoreReceivedRequestToBeDelegateMutation, isIgnoringRequestToBeDelegate } =
- useIgnoreReceivedRequestToBeDelegate();
- const { sendRequestToBeDelegateMutation, isSendingRequestToBeDelegate } = useSendRequestToBeDelegate();
- const { cancelSentRequestToBeDelegateMutation, isCancelingSentRequestToBeDelegate } =
- useCancelSentRequestToBeDelegate();
- const { acceptReceivedRequestToBeDelegateMutation, isAcceptingReceivedRequestToBeDelegate } =
- useAcceptReceivedRequestToBeDelegate();
- const { terminateRelationshipWithDelegateMutation, isTerminatingRelationshipWithDelegate } =
- useTerminateRelationshipWithDelegate();
- const { terminateRelationshipWithDelegatorMutation, isTerminatingRelationshipWithDelegator } =
- useTerminateRelationshipWithDelegator();
+ const {
+ ignoreReceivedRequestToBeDelegateMutation,
+ isIgnoringRequestToBeDelegate,
+ } = useIgnoreReceivedRequestToBeDelegate();
+ const { sendRequestToBeDelegateMutation, isSendingRequestToBeDelegate } =
+ useSendRequestToBeDelegate();
+ const {
+ cancelSentRequestToBeDelegateMutation,
+ isCancelingSentRequestToBeDelegate,
+ } = useCancelSentRequestToBeDelegate();
+ const {
+ acceptReceivedRequestToBeDelegateMutation,
+ isAcceptingReceivedRequestToBeDelegate,
+ } = useAcceptReceivedRequestToBeDelegate();
+ const {
+ terminateRelationshipWithDelegateMutation,
+ isTerminatingRelationshipWithDelegate,
+ } = useTerminateRelationshipWithDelegate();
+ const {
+ terminateRelationshipWithDelegatorMutation,
+ isTerminatingRelationshipWithDelegator,
+ } = useTerminateRelationshipWithDelegator();
const { voting } = useContractsContext();
const { address } = useUserContext();
const {
@@ -165,12 +178,24 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
function getDelegationStatus(): DelegationStatusT {
if (!address) return "no-wallet-connected";
// if you have neither `DelegatorSet` nor `DelegateSet` events, you are neither a delegate or a delegator
- if (!getHasReceivedRequestsToBeDelegate() && !getHasSentRequestsToBeDelegate() && !getHasDelegatorSetEvents())
+ if (
+ !getHasReceivedRequestsToBeDelegate() &&
+ !getHasSentRequestsToBeDelegate() &&
+ !getHasDelegatorSetEvents()
+ )
return "no-delegation";
// if there is a delegator set for your address, you are a delegate
- if (voterFromDelegate && getAddress(voterFromDelegate) !== getAddress(address)) return "delegate";
+ if (
+ voterFromDelegate &&
+ getAddress(voterFromDelegate) !== getAddress(address)
+ )
+ return "delegate";
// if the `delegateToStaker` mapping for the `delegate` defined in your `voterStakes`, then you are a delegator
- if (delegateToStaker && getAddress(address) === getAddress(delegateToStaker)) return "delegator";
+ if (
+ delegateToStaker &&
+ getAddress(address) === getAddress(delegateToStaker)
+ )
+ return "delegator";
// if the user has received a request to be another wallet's delegate but they have not accepted any, then they are a pending delegate
if (getHasPendingReceivedRequestsToBeDelegate()) return "delegate-pending";
// if the user has sent a request to be another wallet's delegate but the other wallet has not yet accepted, then they are a pending delegator
@@ -184,11 +209,15 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
}
function getHasReceivedRequestsToBeDelegate() {
- return receivedRequestsToBeDelegate && receivedRequestsToBeDelegate.length > 0;
+ return (
+ receivedRequestsToBeDelegate && receivedRequestsToBeDelegate.length > 0
+ );
}
function getHasDelegatorSetEvents() {
- return delegatorSetEventsForDelegate && delegatorSetEventsForDelegate.length > 0;
+ return (
+ delegatorSetEventsForDelegate && delegatorSetEventsForDelegate.length > 0
+ );
}
function getHasPendingReceivedRequestsToBeDelegate() {
@@ -196,9 +225,14 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
}
function getHasPendingSentRequestsToBeDelegate() {
- const pendingSentRequestsToBeDelegate = getPendingSentRequestsToBeDelegate();
- const mostRecentSentRequestToBeDelegate = pendingSentRequestsToBeDelegate.at(-1);
- return mostRecentSentRequestToBeDelegate?.delegate !== zeroAddress && pendingSentRequestsToBeDelegate.length > 0;
+ const pendingSentRequestsToBeDelegate =
+ getPendingSentRequestsToBeDelegate();
+ const mostRecentSentRequestToBeDelegate =
+ pendingSentRequestsToBeDelegate.at(-1);
+ return (
+ mostRecentSentRequestToBeDelegate?.delegate !== zeroAddress &&
+ pendingSentRequestsToBeDelegate.length > 0
+ );
}
function getPendingReceivedRequestsToBeDelegate() {
@@ -208,10 +242,14 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
(delegateSet) =>
!delegatorSetEventsForDelegate?.some(
(delegatorSet) =>
- delegatorSet.delegate === delegateSet.delegate && delegatorSet.delegator === delegatorSet.delegator
+ delegatorSet.delegate === delegateSet.delegate &&
+ delegatorSet.delegator === delegatorSet.delegator
)
)
- ?.filter(({ delegator }) => !ignoredRequestToBeDelegateAddresses?.includes(delegator)) ?? []
+ ?.filter(
+ ({ delegator }) =>
+ !ignoredRequestToBeDelegateAddresses?.includes(delegator)
+ ) ?? []
);
}
@@ -223,7 +261,8 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
(delegateSet) =>
!delegatorSetEventsForDelegator?.some(
(delegatorSet) =>
- delegatorSet.delegate === delegateSet.delegate && delegatorSet.delegator === delegatorSet.delegator
+ delegatorSet.delegate === delegateSet.delegate &&
+ delegatorSet.delegator === delegatorSet.delegator
)
) ?? []
);
@@ -235,9 +274,15 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
voting,
delegateAddress,
notificationMessages: {
- pending: `Requesting ${truncateEthAddress(delegateAddress)} to be your delegate...`,
- success: `Successfully requested ${truncateEthAddress(delegateAddress)} to be your delegate`,
- error: `Failed to request ${truncateEthAddress(delegateAddress)} to be your delegate`,
+ pending: `Requesting ${truncateEthAddress(
+ delegateAddress
+ )} to be your delegate...`,
+ success: `Successfully requested ${truncateEthAddress(
+ delegateAddress
+ )} to be your delegate`,
+ error: `Failed to request ${truncateEthAddress(
+ delegateAddress
+ )} to be your delegate`,
},
},
{
@@ -264,15 +309,24 @@ export function DelegationProvider({ children }: { children: ReactNode }) {
voting,
delegatorAddress,
notificationMessages: {
- pending: `Accepting request to be delegate from ${truncateEthAddress(delegatorAddress)}...`,
- success: `Successfully accepted request to be delegate from ${truncateEthAddress(delegatorAddress)}`,
- error: `Failed to accept request to be delegate from ${truncateEthAddress(delegatorAddress)}`,
+ pending: `Accepting request to be delegate from ${truncateEthAddress(
+ delegatorAddress
+ )}...`,
+ success: `Successfully accepted request to be delegate from ${truncateEthAddress(
+ delegatorAddress
+ )}`,
+ error: `Failed to accept request to be delegate from ${truncateEthAddress(
+ delegatorAddress
+ )}`,
},
});
}
function ignoreReceivedRequestToBeDelegate(delegatorAddress: string) {
- ignoreReceivedRequestToBeDelegateMutation({ userAddress: address, delegatorAddress });
+ ignoreReceivedRequestToBeDelegateMutation({
+ userAddress: address,
+ delegatorAddress,
+ });
}
function terminateRelationshipWithDelegator() {
diff --git a/contexts/ErrorContext.tsx b/contexts/ErrorContext.tsx
index 47505726..b2256f3f 100644
--- a/contexts/ErrorContext.tsx
+++ b/contexts/ErrorContext.tsx
@@ -14,10 +14,14 @@ export const defaultErrorContextState: ErrorContextState = {
clearErrorMessages: () => null,
};
-export const ErrorContext = createContext(defaultErrorContextState);
+export const ErrorContext = createContext(
+ defaultErrorContextState
+);
export function ErrorProvider({ children }: { children: ReactNode }) {
- const [errorMessages, setErrorMessages] = useState>({});
+ const [errorMessages, setErrorMessages] = useState<
+ Record
+ >({});
function addErrorMessage(type: string, message: ReactNode) {
setErrorMessages((prev) => ({
@@ -36,7 +40,9 @@ export function ErrorProvider({ children }: { children: ReactNode }) {
function removeErrorMessage(type: string, message: ReactNode) {
setErrorMessages((prev) => ({
...prev,
- [type]: prev[type] ? prev[type].filter((prevMessage) => prevMessage !== message) : [],
+ [type]: prev[type]
+ ? prev[type].filter((prevMessage) => prevMessage !== message)
+ : [],
}));
}
diff --git a/contexts/NotificationsContext.tsx b/contexts/NotificationsContext.tsx
index 143a9975..e90585c4 100644
--- a/contexts/NotificationsContext.tsx
+++ b/contexts/NotificationsContext.tsx
@@ -1,6 +1,11 @@
import { events } from "helpers";
import { createContext, ReactNode, useEffect, useState } from "react";
-import { NotificationT, PendingNotificationT, SettledEventT, UniqueIdT } from "types";
+import {
+ NotificationT,
+ PendingNotificationT,
+ SettledEventT,
+ UniqueIdT,
+} from "types";
export type NotificationsById = Record;
@@ -16,13 +21,19 @@ export const defaultNotificationsContextState: NotificationsContextState = {
clearNotifications: () => null,
};
-export const NotificationsContext = createContext(defaultNotificationsContextState);
+export const NotificationsContext = createContext(
+ defaultNotificationsContextState
+);
export function NotificationsProvider({ children }: { children: ReactNode }) {
const [notifications, setNotifications] = useState({});
useEffect(() => {
- function handlePendingEvent({ message, id, transactionHash }: PendingNotificationT) {
+ function handlePendingEvent({
+ message,
+ id,
+ transactionHash,
+ }: PendingNotificationT) {
addNotification({
id,
message,
@@ -62,7 +73,11 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
setNotifications((prev) => ({ ...prev, [notification.id]: notification }));
}
- function updatePendingNotification(id: UniqueIdT, message: ReactNode, type: "success" | "error") {
+ function updatePendingNotification(
+ id: UniqueIdT,
+ message: ReactNode,
+ type: "success" | "error"
+ ) {
setNotifications((prev) => ({
...prev,
[id]: {
diff --git a/contexts/PaginationContext.tsx b/contexts/PaginationContext.tsx
index 266dd4ec..050ed554 100644
--- a/contexts/PaginationContext.tsx
+++ b/contexts/PaginationContext.tsx
@@ -8,7 +8,10 @@ export interface PaginationContextState {
previousPage: (paginateFor: PaginateForT) => void;
firstPage: (paginateFor: PaginateForT) => void;
lastPage: (paginateFor: PaginateForT, lastPageNumber: number) => void;
- setResultsPerPage: (paginateFor: PaginateForT, resultsPerPage: number) => void;
+ setResultsPerPage: (
+ paginateFor: PaginateForT,
+ resultsPerPage: number
+ ) => void;
}
export const defaultPageState = {
@@ -33,7 +36,9 @@ export const defaultPaginationContextState: PaginationContextState = {
setResultsPerPage: () => null,
};
-export const PaginationContext = createContext(defaultPaginationContextState);
+export const PaginationContext = createContext(
+ defaultPaginationContextState
+);
export function PaginationProvider({ children }: { children: ReactNode }) {
const [pageStates, setPageStates] = useState(defaultPageStates);
@@ -62,7 +67,10 @@ export function PaginationProvider({ children }: { children: ReactNode }) {
});
}
- function setResultsPerPage(paginateFor: PaginateForT, resultsPerPage: number) {
+ function setResultsPerPage(
+ paginateFor: PaginateForT,
+ resultsPerPage: number
+ ) {
setPageStates((prev) => {
const newState = { ...prev };
newState[paginateFor].resultsPerPage = resultsPerPage;
diff --git a/contexts/PanelContext.tsx b/contexts/PanelContext.tsx
index e06514f9..1f1dbeab 100644
--- a/contexts/PanelContext.tsx
+++ b/contexts/PanelContext.tsx
@@ -17,11 +17,15 @@ export const defaultPanelContextState = {
closePanel: () => null,
};
-export const PanelContext = createContext(defaultPanelContextState);
+export const PanelContext = createContext(
+ defaultPanelContextState
+);
export function PanelProvider({ children }: { children: ReactNode }) {
const [panelType, setPanelType] = useState(null);
- const [panelContent, setPanelContent] = useState(null);
+ const [panelContent, setPanelContent] = useState(
+ null
+ );
const [panelOpen, setPanelOpen] = useState(false);
const [previousPanelData, setPreviousPanelData] = useState<
{ panelType: PanelTypeT; panelContent: PanelContentT | undefined }[]
@@ -51,7 +55,10 @@ export function PanelProvider({ children }: { children: ReactNode }) {
}
}
- function pushPanelDataOntoStack(panelType: PanelTypeT, panelContent?: PanelContentT) {
+ function pushPanelDataOntoStack(
+ panelType: PanelTypeT,
+ panelContent?: PanelContentT
+ ) {
setPreviousPanelData((prev) => {
return [...prev, { panelType, panelContent }];
});
diff --git a/contexts/StakingContext.tsx b/contexts/StakingContext.tsx
index 56c98881..ed66c142 100644
--- a/contexts/StakingContext.tsx
+++ b/contexts/StakingContext.tsx
@@ -35,7 +35,9 @@ export const defaultStakingContextState: StakingContextState = {
getStakingDataFetching: () => false,
};
-export const StakingContext = createContext(defaultStakingContextState);
+export const StakingContext = createContext(
+ defaultStakingContextState
+);
export function StakingProvider({ children }: { children: ReactNode }) {
const {
diff --git a/contexts/UserContext.tsx b/contexts/UserContext.tsx
index 9bbd4791..822e5683 100644
--- a/contexts/UserContext.tsx
+++ b/contexts/UserContext.tsx
@@ -41,10 +41,13 @@ export const defaultUserContextState: UserContextState = {
userDataFetching: false,
};
-export const UserContext = createContext(defaultUserContextState);
+export const UserContext = createContext(
+ defaultUserContextState
+);
export function UserProvider({ children }: { children: ReactNode }) {
- const { connectedWallet, account, address, truncatedAddress } = useAccountDetails();
+ const { connectedWallet, account, address, truncatedAddress } =
+ useAccountDetails();
const {
data: {
apr,
diff --git a/contexts/VoteTimingContext.tsx b/contexts/VoteTimingContext.tsx
index f706249e..0edad329 100644
--- a/contexts/VoteTimingContext.tsx
+++ b/contexts/VoteTimingContext.tsx
@@ -1,4 +1,9 @@
-import { computeMillisecondsUntilPhaseEnds, computePhaseEndTimeMilliseconds, computeRoundId, getPhase } from "helpers";
+import {
+ computeMillisecondsUntilPhaseEnds,
+ computePhaseEndTimeMilliseconds,
+ computeRoundId,
+ getPhase,
+} from "helpers";
import { createContext, ReactNode, useState } from "react";
export interface VoteTimingContextState {
@@ -27,7 +32,9 @@ export const defaultVoteTimingContextState: VoteTimingContextState = {
setMillisecondsUntilPhaseEnds: () => null,
};
-export const VoteTimingContext = createContext(defaultVoteTimingContextState);
+export const VoteTimingContext = createContext(
+ defaultVoteTimingContextState
+);
export function VoteTimingProvider({ children }: { children: ReactNode }) {
const [roundId, setRoundId] = useState(defaultVoteTimingContextState.roundId);
@@ -35,7 +42,9 @@ export function VoteTimingProvider({ children }: { children: ReactNode }) {
const [phaseEndTimeMilliseconds, setPhaseEndTimeMilliseconds] = useState(
defaultVoteTimingContextState.phaseEndTimeMilliseconds
);
- const [phaseEndTimeAsDate, setPhaseEndTimeAsDate] = useState(defaultVoteTimingContextState.phaseEndTimeAsDate);
+ const [phaseEndTimeAsDate, setPhaseEndTimeAsDate] = useState(
+ defaultVoteTimingContextState.phaseEndTimeAsDate
+ );
const [millisecondsUntilPhaseEnds, setMillisecondsUntilPhaseEnds] = useState(
defaultVoteTimingContextState.millisecondsUntilPhaseEnds
);
diff --git a/contexts/VotesContext.tsx b/contexts/VotesContext.tsx
index aea57aab..dda0ca4c 100644
--- a/contexts/VotesContext.tsx
+++ b/contexts/VotesContext.tsx
@@ -71,7 +71,9 @@ export const defaultVotesContextState: VotesContextState = {
getIsFetching: () => false,
};
-export const VotesContext = createContext(defaultVotesContextState);
+export const VotesContext = createContext(
+ defaultVotesContextState
+);
export function VotesProvider({ children }: { children: ReactNode }) {
const {
@@ -79,13 +81,21 @@ export function VotesProvider({ children }: { children: ReactNode }) {
isLoading: hasActiveVotesIsLoading,
isFetching: hasActiveVotesIsFetching,
} = useHasActiveVotes();
- const { data: activeVotes, isLoading: activeVotesIsLoading, isFetching: activeVotesIsFetching } = useActiveVotes();
+ const {
+ data: activeVotes,
+ isLoading: activeVotesIsLoading,
+ isFetching: activeVotesIsFetching,
+ } = useActiveVotes();
const {
data: { upcomingVotes, hasUpcomingVotes },
isLoading: upcomingVotesIsLoading,
isFetching: upcomingVotesIsFetching,
} = useUpcomingVotes();
- const { data: pastVotes, isLoading: pastVotesIsLoading, isFetching: pastVotesIsFetching } = usePastVotes();
+ const {
+ data: pastVotes,
+ isLoading: pastVotesIsLoading,
+ isFetching: pastVotesIsFetching,
+ } = usePastVotes();
const {
data: transactionHashes,
isLoading: transactionHashesIsLoading,
diff --git a/contexts/WalletContext.tsx b/contexts/WalletContext.tsx
index 0ac1636e..b8ce8a35 100644
--- a/contexts/WalletContext.tsx
+++ b/contexts/WalletContext.tsx
@@ -26,17 +26,29 @@ export const defaultWalletContextState = {
setSigningKeys: () => null,
};
-export const WalletContext = createContext(defaultWalletContextState);
+export const WalletContext = createContext(
+ defaultWalletContextState
+);
export function WalletProvider({ children }: { children: ReactNode }) {
const [onboard, setOnboard] = useState(initOnboard);
- const [provider, setProvider] = useState(null);
+ const [provider, setProvider] =
+ useState(null);
const [signer, setSigner] = useState(null);
const [signingKeys, setSigningKeys] = useState({});
return (
{children}
diff --git a/contexts/index.ts b/contexts/index.ts
index 27815c12..58b1713e 100644
--- a/contexts/index.ts
+++ b/contexts/index.ts
@@ -1,21 +1,65 @@
-export { ContractsContext, ContractsProvider, defaultContractContextState } from "./ContractsContext";
+export {
+ ContractsContext,
+ ContractsProvider,
+ defaultContractContextState,
+} from "./ContractsContext";
export type { ContractsContextState } from "./ContractsContext";
-export { defaultDelegationContextState, DelegationContext, DelegationProvider } from "./DelegationContext";
+export {
+ defaultDelegationContextState,
+ DelegationContext,
+ DelegationProvider,
+} from "./DelegationContext";
export type { DelegationContextState } from "./DelegationContext";
-export { defaultErrorContextState, ErrorContext, ErrorProvider } from "./ErrorContext";
+export {
+ defaultErrorContextState,
+ ErrorContext,
+ ErrorProvider,
+} from "./ErrorContext";
export type { ErrorContextState } from "./ErrorContext";
-export { defaultNotificationsContextState, NotificationsContext, NotificationsProvider } from "./NotificationsContext";
-export { defaultPaginationContextState, PaginationContext, PaginationProvider } from "./PaginationContext";
+export {
+ defaultNotificationsContextState,
+ NotificationsContext,
+ NotificationsProvider,
+} from "./NotificationsContext";
+export {
+ defaultPaginationContextState,
+ PaginationContext,
+ PaginationProvider,
+} from "./PaginationContext";
export type { PaginationContextState } from "./PaginationContext";
-export { defaultPanelContextState, PanelContext, PanelProvider } from "./PanelContext";
+export {
+ defaultPanelContextState,
+ PanelContext,
+ PanelProvider,
+} from "./PanelContext";
export type { PanelContextState } from "./PanelContext";
-export { defaultStakingContextState, StakingContext, StakingProvider } from "./StakingContext";
+export {
+ defaultStakingContextState,
+ StakingContext,
+ StakingProvider,
+} from "./StakingContext";
export type { StakingContextState } from "./StakingContext";
-export { defaultUserContextState, UserContext, UserProvider } from "./UserContext";
+export {
+ defaultUserContextState,
+ UserContext,
+ UserProvider,
+} from "./UserContext";
export type { UserContextState } from "./UserContext";
-export { defaultVotesContextState, VotesContext, VotesProvider } from "./VotesContext";
+export {
+ defaultVotesContextState,
+ VotesContext,
+ VotesProvider,
+} from "./VotesContext";
export type { VotesContextState } from "./VotesContext";
-export { defaultVoteTimingContextState, VoteTimingContext, VoteTimingProvider } from "./VoteTimingContext";
+export {
+ defaultVoteTimingContextState,
+ VoteTimingContext,
+ VoteTimingProvider,
+} from "./VoteTimingContext";
export type { VoteTimingContextState } from "./VoteTimingContext";
-export { defaultWalletContextState, WalletContext, WalletProvider } from "./WalletContext";
+export {
+ defaultWalletContextState,
+ WalletContext,
+ WalletProvider,
+} from "./WalletContext";
export type { WalletContextState } from "./WalletContext";
diff --git a/data/approvedIdentifiersTable.ts b/data/approvedIdentifiersTable.ts
index 130aeb34..9df17c6f 100644
--- a/data/approvedIdentifiersTable.ts
+++ b/data/approvedIdentifiersTable.ts
@@ -1,6 +1,7 @@
import { IdentifierDetailsT } from "types";
import approvedIdentifiersTable from "./approvedIdentifiersTable.json";
-const approvedIdentifiers: Record = approvedIdentifiersTable;
+const approvedIdentifiers: Record =
+ approvedIdentifiersTable;
export default approvedIdentifiers;
diff --git a/graph/queries/getPastVotes.ts b/graph/queries/getPastVotes.ts
index af55a4b2..cab2a11f 100644
--- a/graph/queries/getPastVotes.ts
+++ b/graph/queries/getPastVotes.ts
@@ -1,13 +1,22 @@
-import graphEndpoint from "constants/graphEndpoint";
+import { graphEndpoint } from "constant";
import { BigNumber } from "ethers";
import request, { gql } from "graphql-request";
-import { formatBytes32String, formatVoteStringWithPrecision, makePriceRequestsByKey, parseEther } from "helpers";
+import {
+ formatBytes32String,
+ formatVoteStringWithPrecision,
+ makePriceRequestsByKey,
+ parseEther,
+} from "helpers";
import { PastVotesQuery } from "types";
export async function getPastVotes() {
const pastVotesQuery = gql`
{
- priceRequests(where: { isResolved: true }, orderBy: time, orderDirection: desc) {
+ priceRequests(
+ where: { isResolved: true }
+ orderBy: time
+ orderDirection: desc
+ ) {
id
identifier {
id
@@ -20,19 +29,23 @@ export async function getPastVotes() {
}
`;
const result = await request(graphEndpoint, pastVotesQuery);
- const parsedData = result?.priceRequests?.map(({ id, time, price, ancillaryData, requestIndex }) => {
- const identifier = getIdentifierFromPriceRequestId(id);
- const correctVote = Number(formatVoteStringWithPrecision(parseEther(price), identifier));
- const priceRequestIndex = BigNumber.from(requestIndex);
+ const parsedData = result?.priceRequests?.map(
+ ({ id, time, price, ancillaryData, requestIndex }) => {
+ const identifier = getIdentifierFromPriceRequestId(id);
+ const correctVote = Number(
+ formatVoteStringWithPrecision(parseEther(price), identifier)
+ );
+ const priceRequestIndex = BigNumber.from(requestIndex);
- return {
- identifier,
- time: Number(time),
- correctVote,
- ancillaryData,
- priceRequestIndex,
- };
- });
+ return {
+ identifier,
+ time: Number(time),
+ correctVote,
+ ancillaryData,
+ priceRequestIndex,
+ };
+ }
+ );
const pastVotes = makePriceRequestsByKey(parsedData ?? []);
diff --git a/graph/queries/getUserVotingAndStakingDetails.ts b/graph/queries/getUserVotingAndStakingDetails.ts
index 38c7b40a..8b886a7d 100644
--- a/graph/queries/getUserVotingAndStakingDetails.ts
+++ b/graph/queries/getUserVotingAndStakingDetails.ts
@@ -1,9 +1,16 @@
-import graphEndpoint from "constants/graphEndpoint";
+import { graphEndpoint } from "constant";
import request, { gql } from "graphql-request";
import { bigNumberFromFloatString } from "helpers";
-import { UserDataQuery, UserDataT, VoteHistoryByKeyT, VoteHistoryT } from "types";
+import {
+ UserDataQuery,
+ UserDataT,
+ VoteHistoryByKeyT,
+ VoteHistoryT,
+} from "types";
-export async function getUserVotingAndStakingDetails(address: string | undefined) {
+export async function getUserVotingAndStakingDetails(
+ address: string | undefined
+) {
const userDataQuery = gql`
{
users(where: { address: "${address}" }) {
@@ -34,13 +41,21 @@ export async function getUserVotingAndStakingDetails(address: string | undefined
return userData;
}
-function parseUserVotingAndStakingDetails(rawUserData: UserDataQuery["users"][0] | undefined) {
+function parseUserVotingAndStakingDetails(
+ rawUserData: UserDataQuery["users"][0] | undefined
+) {
const apr = bigNumberFromFloatString(rawUserData?.annualPercentageReturn);
const countReveals = bigNumberFromFloatString(rawUserData?.countReveals);
const countNoVotes = bigNumberFromFloatString(rawUserData?.countNoVotes);
- const countWrongVotes = bigNumberFromFloatString(rawUserData?.countWrongVotes);
- const countCorrectVotes = bigNumberFromFloatString(rawUserData?.countCorrectVotes);
- const cumulativeCalculatedSlash = bigNumberFromFloatString(rawUserData?.cumulativeCalculatedSlash);
+ const countWrongVotes = bigNumberFromFloatString(
+ rawUserData?.countWrongVotes
+ );
+ const countCorrectVotes = bigNumberFromFloatString(
+ rawUserData?.countCorrectVotes
+ );
+ const cumulativeCalculatedSlash = bigNumberFromFloatString(
+ rawUserData?.cumulativeCalculatedSlash
+ );
const cumulativeCalculatedSlashPercentage = bigNumberFromFloatString(
rawUserData?.cumulativeCalculatedSlashPercentage
);
diff --git a/helpers/getIgnoredRequestToBeDelegateAddressesFromStorage.ts b/helpers/delegation/getIgnoredRequestToBeDelegateAddressesFromStorage.ts
similarity index 100%
rename from helpers/getIgnoredRequestToBeDelegateAddressesFromStorage.ts
rename to helpers/delegation/getIgnoredRequestToBeDelegateAddressesFromStorage.ts
diff --git a/helpers/index.ts b/helpers/index.ts
index 309fe48f..b3b93dda 100644
--- a/helpers/index.ts
+++ b/helpers/index.ts
@@ -1,5 +1,36 @@
-export { addOpacityToHsl } from "./addOpacityToHsl";
-export { checkIfIsPolymarket } from "./checkIfIsPolymarket";
+export { getIgnoredRequestToBeDelegateAddressesFromStorage } from "./delegation/getIgnoredRequestToBeDelegateAddressesFromStorage";
+export { getCanUnstakeTime } from "./staking/getCanUnstakeTime";
+export { addOpacityToHsl } from "./util/addOpacityToHsl";
+export {
+ bigNumberFromFloatString,
+ formatNumberForDisplay,
+ truncateDecimals,
+} from "./util/formatNumber";
+export { getEntriesForPage } from "./util/getEntriesForPage";
+export { handleNotifications } from "./util/handleNotifications";
+export { capitalizeFirstLetter, isExternalLink } from "./util/isExternalLink";
+export { logTruthy } from "./util/logTruthy";
+export { unixTimestampToDate } from "./util/unixTimestampToDate";
+export { checkIfIsPolymarket } from "./voting/checkIfIsPolymarket";
+export {
+ formatVotesToCommit,
+ formatVotesToReveal,
+ formatVoteStringWithPrecision,
+ parseVoteStringWithPrecision,
+} from "./voting/formatVotes";
+export { getVoteMetaData } from "./voting/getVoteMetaData";
+export { makePriceRequestsByKey } from "./voting/makePriceRequestsByKey";
+export { makeUniqueKeyForVote } from "./voting/makeUniqueKeyForVote";
+export { onlyOneRequestPerAddress } from "./voting/onlyOneRequestPerAddress";
+export {
+ computeMillisecondsUntilPhaseEnds,
+ computePhase,
+ computePhaseEndTime,
+ computePhaseEndTimeMilliseconds,
+ computeRoundEndTime,
+ computeRoundId,
+ getPhase,
+} from "./voting/voteTiming";
export {
decryptMessage,
derivePrivateKey,
@@ -10,8 +41,8 @@ export {
IDENTIFIER_BLACKLIST,
IDENTIFIER_NON_18_PRECISION,
recoverPublicKey,
-} from "./crypto";
-export { decodeHexString } from "./decodeHexString";
+} from "./web3/crypto";
+export { decodeHexString } from "./web3/decodeHexString";
export {
commify,
formatBytes32String,
@@ -25,34 +56,13 @@ export {
solidityKeccak256,
toUtf8String,
zeroAddress,
-} from "./ethers";
-export * from "./events";
-export { bigNumberFromFloatString, formatNumberForDisplay, truncateDecimals } from "./formatNumber";
+} from "./web3/ethers";
export {
- formatVotesToCommit,
- formatVotesToReveal,
- formatVoteStringWithPrecision,
- parseVoteStringWithPrecision,
-} from "./formatVotes";
-export { getCanUnstakeTime } from "./getCanUnstakeTime";
-export { getEntriesForPage } from "./getEntriesForPage";
-export { getIgnoredRequestToBeDelegateAddressesFromStorage } from "./getIgnoredRequestToBeDelegateAddressesFromStorage";
-export { getVoteMetaData } from "./getVoteMetaData";
-export { handleNotifications } from "./handleNotifications";
-export { initOnboard } from "./initOnboard";
-export { makePriceRequestsByKey } from "./makePriceRequestsByKey";
-export { isExternalLink } from "./misc";
-export { onlyOneRequestPerAddress } from "./onlyOneRequestPerAddress";
-export { truncateEthAddress } from "./truncateEthAddress";
-export { unixTimestampToDate } from "./unixTimestampToDate";
-export { makeUniqueKeyForVote } from "./votes";
-export {
- computeMillisecondsUntilPhaseEnds,
- computePhase,
- computePhaseEndTime,
- computePhaseEndTimeMilliseconds,
- computeRoundEndTime,
- computeRoundId,
- getPhase,
-} from "./voteTiming";
-export { getAccountDetails, handleDisconnectWallet } from "./wallet";
+ emitErrorEvent,
+ emitPendingEvent,
+ emitSuccessEvent,
+ events,
+} from "./web3/events";
+export { initOnboard } from "./web3/initOnboard";
+export { truncateEthAddress } from "./web3/truncateEthAddress";
+export { getAccountDetails, handleDisconnectWallet } from "./web3/wallet";
diff --git a/helpers/getCanUnstakeTime.ts b/helpers/staking/getCanUnstakeTime.ts
similarity index 62%
rename from helpers/getCanUnstakeTime.ts
rename to helpers/staking/getCanUnstakeTime.ts
index b5811b83..235a47b7 100644
--- a/helpers/getCanUnstakeTime.ts
+++ b/helpers/staking/getCanUnstakeTime.ts
@@ -3,6 +3,9 @@ import addSeconds from "date-fns/addSeconds";
// set 7 day cooldown as default
const defaultUnstakeCoolDown = 7 * 24 * 60 * 60;
-export function getCanUnstakeTime(unstakeRequestTimeAsDate: Date, unstakeCooldownS = defaultUnstakeCoolDown) {
+export function getCanUnstakeTime(
+ unstakeRequestTimeAsDate: Date,
+ unstakeCooldownS = defaultUnstakeCoolDown
+) {
return addSeconds(unstakeRequestTimeAsDate, unstakeCooldownS);
}
diff --git a/helpers/addOpacityToHsl.ts b/helpers/util/addOpacityToHsl.ts
similarity index 100%
rename from helpers/addOpacityToHsl.ts
rename to helpers/util/addOpacityToHsl.ts
diff --git a/helpers/formatNumber.ts b/helpers/util/formatNumber.ts
similarity index 100%
rename from helpers/formatNumber.ts
rename to helpers/util/formatNumber.ts
diff --git a/helpers/getEntriesForPage.ts b/helpers/util/getEntriesForPage.ts
similarity index 55%
rename from helpers/getEntriesForPage.ts
rename to helpers/util/getEntriesForPage.ts
index 6f7381d5..8c589a2e 100644
--- a/helpers/getEntriesForPage.ts
+++ b/helpers/util/getEntriesForPage.ts
@@ -1,4 +1,8 @@
-export function getEntriesForPage(pageNumber: number, resultsPerPage: number, entries: EntryType[]) {
+export function getEntriesForPage(
+ pageNumber: number,
+ resultsPerPage: number,
+ entries: EntryType[]
+) {
const startIndex = (pageNumber - 1) * resultsPerPage;
const endIndex = startIndex + resultsPerPage;
return entries.slice(startIndex, endIndex);
diff --git a/helpers/handleNotifications.ts b/helpers/util/handleNotifications.ts
similarity index 97%
rename from helpers/handleNotifications.ts
rename to helpers/util/handleNotifications.ts
index d066aa50..89d55b11 100644
--- a/helpers/handleNotifications.ts
+++ b/helpers/util/handleNotifications.ts
@@ -1,6 +1,6 @@
import { ContractTransaction } from "ethers";
import { ReactNode } from "react";
-import { emitErrorEvent, emitPendingEvent, emitSuccessEvent } from "./events";
+import { emitErrorEvent, emitPendingEvent, emitSuccessEvent } from "helpers";
export async function handleNotifications(
tx: ContractTransaction,
diff --git a/helpers/misc.ts b/helpers/util/isExternalLink.ts
similarity index 100%
rename from helpers/misc.ts
rename to helpers/util/isExternalLink.ts
diff --git a/helpers/logTruthy.ts b/helpers/util/logTruthy.ts
similarity index 100%
rename from helpers/logTruthy.ts
rename to helpers/util/logTruthy.ts
diff --git a/helpers/unixTimestampToDate.ts b/helpers/util/unixTimestampToDate.ts
similarity index 100%
rename from helpers/unixTimestampToDate.ts
rename to helpers/util/unixTimestampToDate.ts
diff --git a/helpers/checkIfIsPolymarket.ts b/helpers/voting/checkIfIsPolymarket.ts
similarity index 73%
rename from helpers/checkIfIsPolymarket.ts
rename to helpers/voting/checkIfIsPolymarket.ts
index 32bb2a41..69a1d250 100644
--- a/helpers/checkIfIsPolymarket.ts
+++ b/helpers/voting/checkIfIsPolymarket.ts
@@ -1,4 +1,7 @@
-export function checkIfIsPolymarket(decodedIdentifier: string, decodedAncillaryData: string) {
+export function checkIfIsPolymarket(
+ decodedIdentifier: string,
+ decodedAncillaryData: string
+) {
const queryTitleToken = "q: title:";
const resultDataToken = "res_data:";
const isPolymarket =
diff --git a/helpers/formatVotes.ts b/helpers/voting/formatVotes.ts
similarity index 71%
rename from helpers/formatVotes.ts
rename to helpers/voting/formatVotes.ts
index e2884d1c..c60c0843 100644
--- a/helpers/formatVotes.ts
+++ b/helpers/voting/formatVotes.ts
@@ -1,8 +1,12 @@
import { formatFixed, parseFixed } from "@ethersproject/bignumber";
import { BigNumber, BigNumberish } from "ethers";
-import { solidityKeccak256 } from "helpers";
+import {
+ encryptMessage,
+ getPrecisionForIdentifier,
+ getRandomSignedInt,
+ solidityKeccak256,
+} from "helpers";
import { FormatVotesToCommit, VoteFormattedToCommitT, VoteT } from "types";
-import { encryptMessage, getPrecisionForIdentifier, getRandomSignedInt } from "./crypto";
function makeVoteHash(
price: string,
@@ -35,7 +39,9 @@ export async function formatVotesToCommit({
// this should have been saved in local storage when the user connected their wallet
const hasSignedMessage = Boolean(signingKeys[address].signedMessage);
if (!hasSignedMessage) {
- throw new Error("You must sign the message to commit votes. Please re-connect your wallet and try again.");
+ throw new Error(
+ "You must sign the message to commit votes. Please re-connect your wallet and try again."
+ );
}
const formattedVotes = await Promise.all(
@@ -47,11 +53,25 @@ export async function formatVotesToCommit({
const { identifier, decodedIdentifier, ancillaryData, time } = vote;
// the selected option for a vote is called `price` for legacy reasons
- const price = parseVoteStringWithPrecision(selectedVote, decodedIdentifier);
+ const price = parseVoteStringWithPrecision(
+ selectedVote,
+ decodedIdentifier
+ );
// the hash must be created with exactly these values in exactly this order
- const hash = makeVoteHash(price, salt, account, time, ancillaryData, roundId, identifier);
+ const hash = makeVoteHash(
+ price,
+ salt,
+ account,
+ time,
+ ancillaryData,
+ roundId,
+ identifier
+ );
// encrypt the hash with the signed message we created when the user first connected their wallet
- const encryptedVote = await encryptMessage(signingPublicKey, JSON.stringify({ price, salt }));
+ const encryptedVote = await encryptMessage(
+ signingPublicKey,
+ JSON.stringify({ price, salt })
+ );
return {
...vote,
@@ -61,7 +81,9 @@ export async function formatVotesToCommit({
})
);
- return formattedVotes.filter((vote): vote is VoteFormattedToCommitT => Boolean(vote));
+ return formattedVotes.filter((vote): vote is VoteFormattedToCommitT =>
+ Boolean(vote)
+ );
}
export function formatVotesToReveal(decryptedVotesForUser: VoteT[]) {
return decryptedVotesForUser.flatMap((vote) => {
@@ -80,14 +102,24 @@ export function formatVotesToReveal(decryptedVotesForUser: VoteT[]) {
});
}
-export function parseVoteStringWithPrecision(vote: string, decodedIdentifier: string) {
+export function parseVoteStringWithPrecision(
+ vote: string,
+ decodedIdentifier: string
+) {
// check the precision to use from our table of precisions
- const identifierPrecision = BigNumber.from(getPrecisionForIdentifier(decodedIdentifier)).toString();
+ const identifierPrecision = BigNumber.from(
+ getPrecisionForIdentifier(decodedIdentifier)
+ ).toString();
return parseFixed(vote, identifierPrecision).toString();
}
-export function formatVoteStringWithPrecision(vote: BigNumberish, decodedIdentifier: string) {
+export function formatVoteStringWithPrecision(
+ vote: BigNumberish,
+ decodedIdentifier: string
+) {
// check the precision to use from our table of precisions
- const identifierPrecision = BigNumber.from(getPrecisionForIdentifier(decodedIdentifier)).toString();
+ const identifierPrecision = BigNumber.from(
+ getPrecisionForIdentifier(decodedIdentifier)
+ ).toString();
return formatFixed(vote, identifierPrecision).toString();
}
diff --git a/helpers/getVoteMetaData.ts b/helpers/voting/getVoteMetaData.ts
similarity index 84%
rename from helpers/getVoteMetaData.ts
rename to helpers/voting/getVoteMetaData.ts
index 2b0e9419..58123130 100644
--- a/helpers/getVoteMetaData.ts
+++ b/helpers/voting/getVoteMetaData.ts
@@ -1,5 +1,4 @@
-import { discordLink } from "constants/discordLink";
-import earlyRequestMagicNumber from "constants/earlyRequestMagicNumber";
+import { discordLink, earlyRequestMagicNumber } from "constant";
import approvedIdentifiers from "data/approvedIdentifiersTable";
import { checkIfIsPolymarket } from "helpers";
import { ContentfulDataT, VoteMetaDataT } from "types";
@@ -24,7 +23,9 @@ export function getVoteMetaData(
const isUmip = decodedIdentifier.includes("Admin");
if (isUmip) {
const title = umipDataFromContentful?.title ?? decodedIdentifier;
- const description = umipDataFromContentful?.description ?? "No description was found for this UMIP.";
+ const description =
+ umipDataFromContentful?.description ??
+ "No description was found for this UMIP.";
const umipUrl = umipDataFromContentful?.umipLink;
const umipNumber = getUmipNumber(decodedIdentifier);
const links = makeVoteLinks(transactionHash, umipNumber);
@@ -43,12 +44,17 @@ export function getVoteMetaData(
};
}
- const isPolymarket = checkIfIsPolymarket(decodedIdentifier, decodedAncillaryData);
+ const isPolymarket = checkIfIsPolymarket(
+ decodedIdentifier,
+ decodedAncillaryData
+ );
if (isPolymarket) {
const ancillaryDataTitle = getTitleFromAncillaryData(decodedAncillaryData);
- const ancillaryDataDescription = getDescriptionFromAncillaryData(decodedAncillaryData);
+ const ancillaryDataDescription =
+ getDescriptionFromAncillaryData(decodedAncillaryData);
const title = ancillaryDataTitle ?? decodedIdentifier;
- const description = ancillaryDataDescription ?? "No description was found for this request.";
+ const description =
+ ancillaryDataDescription ?? "No description was found for this request.";
const links = makeVoteLinks(transactionHash);
const isYesNoQuery = decodedIdentifier === "YES_OR_NO_QUERY";
const options = isYesNoQuery ? makeVoteOptions("yesNoQuery") : undefined;
@@ -111,18 +117,25 @@ function getTitleFromAncillaryData(
descriptionIdentifier = "description:"
) {
const start = decodedAncillaryData.indexOf(titleIdentifier);
- const end = decodedAncillaryData.indexOf(descriptionIdentifier) ?? decodedAncillaryData.length;
+ const end =
+ decodedAncillaryData.indexOf(descriptionIdentifier) ??
+ decodedAncillaryData.length;
if (start === -1) {
return undefined;
}
- const title = decodedAncillaryData.substring(start + titleIdentifier.length, end).trim();
+ const title = decodedAncillaryData
+ .substring(start + titleIdentifier.length, end)
+ .trim();
// remove the trailing comma if it exists (from Polymarket)
return title.endsWith(",") ? title.slice(0, -1) : title;
}
-function getDescriptionFromAncillaryData(decodedAncillaryData: string, descriptionIdentifier = "description:") {
+function getDescriptionFromAncillaryData(
+ decodedAncillaryData: string,
+ descriptionIdentifier = "description:"
+) {
if (!decodedAncillaryData) {
return undefined;
}
@@ -133,7 +146,10 @@ function getDescriptionFromAncillaryData(decodedAncillaryData: string, descripti
return undefined;
}
- return decodedAncillaryData.substring(start + descriptionIdentifier.length, end);
+ return decodedAncillaryData.substring(
+ start + descriptionIdentifier.length,
+ end
+ );
}
function getUmipNumber(umipOrAdmin: string | undefined) {
@@ -152,7 +168,11 @@ function makeVoteOptions(voteType: "umip" | "yesNoQuery") {
{ label: "Yes", value: "0", secondaryLabel: "p1" },
{ label: "No", value: "1", secondaryLabel: "p2" },
{ label: "Unknown", value: "0.5", secondaryLabel: "p3" },
- { label: "Early request", value: earlyRequestMagicNumber, secondaryLabel: "p4" },
+ {
+ label: "Early request",
+ value: earlyRequestMagicNumber,
+ secondaryLabel: "p4",
+ },
];
const umipVoteOptions = [
{ label: "Yes", value: "1" },
diff --git a/helpers/makePriceRequestsByKey.ts b/helpers/voting/makePriceRequestsByKey.ts
similarity index 74%
rename from helpers/makePriceRequestsByKey.ts
rename to helpers/voting/makePriceRequestsByKey.ts
index 8bf46787..7c1d2bf5 100644
--- a/helpers/makePriceRequestsByKey.ts
+++ b/helpers/voting/makePriceRequestsByKey.ts
@@ -1,8 +1,10 @@
import { PriceRequestByKeyT, PriceRequestT, RawPriceRequestDataT } from "types";
-import { decodeHexString } from "./decodeHexString";
-import { makeUniqueKeyForVote } from "./votes";
+import { decodeHexString } from "helpers";
+import { makeUniqueKeyForVote } from "helpers";
-export function makePriceRequestsByKey(priceRequests: RawPriceRequestDataT[] | undefined) {
+export function makePriceRequestsByKey(
+ priceRequests: RawPriceRequestDataT[] | undefined
+) {
const priceRequestsByKey: PriceRequestByKeyT = {};
if (priceRequests?.length) {
@@ -16,7 +18,9 @@ export function makePriceRequestsByKey(priceRequests: RawPriceRequestDataT[] | u
}
function formatPriceRequests(priceRequests: RawPriceRequestDataT[]) {
- return priceRequests.map(formatPriceRequest).filter((priceRequest): priceRequest is PriceRequestT => !!priceRequest);
+ return priceRequests
+ .map(formatPriceRequest)
+ .filter((priceRequest): priceRequest is PriceRequestT => !!priceRequest);
}
function formatPriceRequest(priceRequest: RawPriceRequestDataT) {
@@ -29,7 +33,11 @@ function formatPriceRequest(priceRequest: RawPriceRequestDataT) {
const decodedIdentifier = decodeHexString(identifier);
const decodedAncillaryData = decodeHexString(ancillaryData);
const correctVote = priceRequest.correctVote;
- const uniqueKey = makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData);
+ const uniqueKey = makeUniqueKeyForVote(
+ decodedIdentifier,
+ time,
+ ancillaryData
+ );
return {
time,
diff --git a/helpers/votes.ts b/helpers/voting/makeUniqueKeyForVote.ts
similarity index 56%
rename from helpers/votes.ts
rename to helpers/voting/makeUniqueKeyForVote.ts
index fd96ee18..f414045e 100644
--- a/helpers/votes.ts
+++ b/helpers/voting/makeUniqueKeyForVote.ts
@@ -1,6 +1,10 @@
import { BigNumber } from "ethers";
-export function makeUniqueKeyForVote(decodedIdentifier: string, time: number | BigNumber, ancillaryData: string) {
+export function makeUniqueKeyForVote(
+ decodedIdentifier: string,
+ time: number | BigNumber,
+ ancillaryData: string
+) {
if (typeof time !== "number") {
time = time.toNumber();
}
diff --git a/helpers/onlyOneRequestPerAddress.ts b/helpers/voting/onlyOneRequestPerAddress.ts
similarity index 76%
rename from helpers/onlyOneRequestPerAddress.ts
rename to helpers/voting/onlyOneRequestPerAddress.ts
index e19eb978..12bc8f0e 100644
--- a/helpers/onlyOneRequestPerAddress.ts
+++ b/helpers/voting/onlyOneRequestPerAddress.ts
@@ -1,6 +1,9 @@
import { DelegationEventT } from "types";
-export function onlyOneRequestPerAddress(delegationEvents: DelegationEventT[], queryFor: "delegate" | "delegator") {
+export function onlyOneRequestPerAddress(
+ delegationEvents: DelegationEventT[],
+ queryFor: "delegate" | "delegator"
+) {
const uniqueAddresses = new Set();
const requestsFromUniqueAddresses: DelegationEventT[] = [];
diff --git a/helpers/voteTiming.ts b/helpers/voting/voteTiming.ts
similarity index 95%
rename from helpers/voteTiming.ts
rename to helpers/voting/voteTiming.ts
index 02f93cef..bc900d43 100644
--- a/helpers/voteTiming.ts
+++ b/helpers/voting/voteTiming.ts
@@ -1,4 +1,4 @@
-import { numPhases, phaseLength, roundLength } from "constants/voteTiming";
+import { numPhases, phaseLength, roundLength } from "constant";
/** Computes the round ID with the current time */
export function computeRoundId() {
diff --git a/helpers/crypto.ts b/helpers/web3/crypto.ts
similarity index 80%
rename from helpers/crypto.ts
rename to helpers/web3/crypto.ts
index 874bdaff..bed98edc 100644
--- a/helpers/crypto.ts
+++ b/helpers/web3/crypto.ts
@@ -4,13 +4,24 @@ import { randomBytes, solidityKeccak256 } from "helpers";
// Encrypts a message using an ethereum public key. To decrypt messages that are encrypted with this method, use
// decryptMessage().
-export async function encryptMessage(publicKey: string, message: string): Promise {
- const encryptedMessageObject = await EthCrypto.encryptWithPublicKey(publicKey, message);
+export async function encryptMessage(
+ publicKey: string,
+ message: string
+): Promise {
+ const encryptedMessageObject = await EthCrypto.encryptWithPublicKey(
+ publicKey,
+ message
+ );
return "0x" + EthCrypto.cipher.stringify(encryptedMessageObject);
}
-export async function decryptMessage(privKey: string, encryptedMessage: string): Promise {
- const encryptedMessageObject = EthCrypto.cipher.parse(encryptedMessage.slice(2));
+export async function decryptMessage(
+ privKey: string,
+ encryptedMessage: string
+): Promise {
+ const encryptedMessageObject = EthCrypto.cipher.parse(
+ encryptedMessage.slice(2)
+ );
return await EthCrypto.decryptWithPrivateKey(privKey, encryptedMessageObject);
}
@@ -37,12 +48,16 @@ export const IDENTIFIER_NON_18_PRECISION = {
type IdentifierNon18Precision = keyof typeof IDENTIFIER_NON_18_PRECISION;
-function isNon18Precision(identifier: string): identifier is IdentifierNon18Precision {
+function isNon18Precision(
+ identifier: string
+): identifier is IdentifierNon18Precision {
return identifier in IDENTIFIER_NON_18_PRECISION;
}
export const getPrecisionForIdentifier = (identifier: string): number => {
- return isNon18Precision(identifier) ? IDENTIFIER_NON_18_PRECISION[identifier] : 18;
+ return isNon18Precision(identifier)
+ ? IDENTIFIER_NON_18_PRECISION[identifier]
+ : 18;
};
export function getRandomSignedInt(): BigNumber {
diff --git a/helpers/decodeHexString.ts b/helpers/web3/decodeHexString.ts
similarity index 100%
rename from helpers/decodeHexString.ts
rename to helpers/web3/decodeHexString.ts
diff --git a/helpers/ethers.ts b/helpers/web3/ethers.ts
similarity index 96%
rename from helpers/ethers.ts
rename to helpers/web3/ethers.ts
index fc21b5f7..127985c6 100644
--- a/helpers/ethers.ts
+++ b/helpers/web3/ethers.ts
@@ -1,5 +1,5 @@
import { ethers } from "ethers";
-import { capitalizeFirstLetter } from "./misc";
+import { capitalizeFirstLetter } from "helpers";
export const formatEther = ethers.utils.formatEther;
diff --git a/helpers/events.ts b/helpers/web3/events.ts
similarity index 59%
rename from helpers/events.ts
rename to helpers/web3/events.ts
index 5dc0d7a3..efffa180 100644
--- a/helpers/events.ts
+++ b/helpers/web3/events.ts
@@ -4,19 +4,28 @@ import uniqueId from "lodash/uniqueId";
export const events = new Events();
-export function emitSuccessEvent(successEvent: { message: ReactNode; pendingId: string }) {
+export function emitSuccessEvent(successEvent: {
+ message: ReactNode;
+ pendingId: string;
+}) {
const id = uniqueId();
events.emit("success", { ...successEvent, id });
return id;
}
-export function emitErrorEvent(errorEvent: { message: ReactNode; pendingId: string }) {
+export function emitErrorEvent(errorEvent: {
+ message: ReactNode;
+ pendingId: string;
+}) {
const id = uniqueId();
events.emit("error", { ...errorEvent, id: uniqueId() });
return id;
}
-export function emitPendingEvent(pendingEvent: { message: ReactNode; transactionHash: string }) {
+export function emitPendingEvent(pendingEvent: {
+ message: ReactNode;
+ transactionHash: string;
+}) {
const id = uniqueId();
events.emit("pending", { ...pendingEvent, id });
return id;
diff --git a/helpers/initOnboard.ts b/helpers/web3/initOnboard.ts
similarity index 92%
rename from helpers/initOnboard.ts
rename to helpers/web3/initOnboard.ts
index cf422738..3130121e 100644
--- a/helpers/initOnboard.ts
+++ b/helpers/web3/initOnboard.ts
@@ -32,7 +32,9 @@ export const initOnboard = init({
icon: logo,
logo,
description: "UMA 2.0 Voter Dapp",
- recommendedInjectedWallets: [{ name: "MetaMask", url: "https://metamask.io" }],
+ recommendedInjectedWallets: [
+ { name: "MetaMask", url: "https://metamask.io" },
+ ],
},
apiKey: blocknativeDappId,
notify: {
diff --git a/helpers/truncateEthAddress.ts b/helpers/web3/truncateEthAddress.ts
similarity index 100%
rename from helpers/truncateEthAddress.ts
rename to helpers/web3/truncateEthAddress.ts
diff --git a/helpers/wallet.ts b/helpers/web3/wallet.ts
similarity index 100%
rename from helpers/wallet.ts
rename to helpers/web3/wallet.ts
diff --git a/hooks/helpers/useInitializeVoteTiming.ts b/hooks/helpers/useInitializeVoteTiming.ts
index b7e3f585..2c54f4b7 100644
--- a/hooks/helpers/useInitializeVoteTiming.ts
+++ b/hooks/helpers/useInitializeVoteTiming.ts
@@ -1,4 +1,9 @@
-import { computeMillisecondsUntilPhaseEnds, computePhaseEndTimeMilliseconds, computeRoundId, getPhase } from "helpers";
+import {
+ computeMillisecondsUntilPhaseEnds,
+ computePhaseEndTimeMilliseconds,
+ computeRoundId,
+ getPhase,
+} from "helpers";
import { useInterval, useVoteTimingContext } from "hooks";
/** Initializes the vote timing interval
@@ -8,8 +13,13 @@ import { useInterval, useVoteTimingContext } from "hooks";
* This hook only needs to be called once on initialization of the dapp.
*/
export function useInitializeVoteTiming() {
- const { setRoundId, setPhase, setPhaseEndTimeMilliseconds, setPhaseEndTimeAsDate, setMillisecondsUntilPhaseEnds } =
- useVoteTimingContext();
+ const {
+ setRoundId,
+ setPhase,
+ setPhaseEndTimeMilliseconds,
+ setPhaseEndTimeAsDate,
+ setMillisecondsUntilPhaseEnds,
+ } = useVoteTimingContext();
useInterval(() => {
setRoundId(computeRoundId());
diff --git a/hooks/helpers/useIsomorphicLayoutEffect.ts b/hooks/helpers/useIsomorphicLayoutEffect.ts
index 1701fca1..1c47b0e3 100644
--- a/hooks/helpers/useIsomorphicLayoutEffect.ts
+++ b/hooks/helpers/useIsomorphicLayoutEffect.ts
@@ -4,4 +4,5 @@ import { useEffect, useLayoutEffect } from "react";
*
* See https://usehooks-ts.com/react-hook/use-isomorphic-layout-effect for more details.
*/
-export const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
+export const useIsomorphicLayoutEffect =
+ typeof window !== "undefined" ? useLayoutEffect : useEffect;
diff --git a/hooks/helpers/useOnChange.ts b/hooks/helpers/useOnChange.ts
index 401835b7..fba712fd 100644
--- a/hooks/helpers/useOnChange.ts
+++ b/hooks/helpers/useOnChange.ts
@@ -20,7 +20,9 @@ export function useOnChange(
const decimalsErrorMessage = `Cannot have more than ${maxDecimals} decimals.`;
const negativeAllowedDecimalRegex = /^-?\d*\.?\d{0,}$/;
const onlyPositiveDecimalsRegex = /^\d*\.?\d{0,}$/;
- const decimalsRegex = allowNegative ? negativeAllowedDecimalRegex : onlyPositiveDecimalsRegex;
+ const decimalsRegex = allowNegative
+ ? negativeAllowedDecimalRegex
+ : onlyPositiveDecimalsRegex;
const isValidDecimalNumber = decimalsRegex.test(value);
if (!isValidDecimalNumber) return;
diff --git a/hooks/mutations/delegation/useAcceptReceivedRequestToBeDelegate.ts b/hooks/mutations/delegation/useAcceptReceivedRequestToBeDelegate.ts
index 53f239a0..bf98dfbd 100644
--- a/hooks/mutations/delegation/useAcceptReceivedRequestToBeDelegate.ts
+++ b/hooks/mutations/delegation/useAcceptReceivedRequestToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { delegateToStakerKey, voterFromDelegateKey } from "constants/queryKeys";
+import { delegateToStakerKey, voterFromDelegateKey } from "constant";
import { useHandleError, useUserContext } from "hooks";
import { setDelegator } from "web3";
@@ -11,8 +11,14 @@ export function useAcceptReceivedRequestToBeDelegate() {
const { mutate, isLoading } = useMutation(setDelegator, {
onError,
onSuccess: (_data, { delegatorAddress }) => {
- queryClient.setQueryData([voterFromDelegateKey, address], () => delegatorAddress);
- queryClient.setQueryData([delegateToStakerKey, address], () => address);
+ queryClient.setQueryData(
+ [voterFromDelegateKey, address],
+ () => delegatorAddress
+ );
+ queryClient.setQueryData(
+ [delegateToStakerKey, address],
+ () => address
+ );
},
});
diff --git a/hooks/mutations/delegation/useCancelSentRequestToBeDelegate.ts b/hooks/mutations/delegation/useCancelSentRequestToBeDelegate.ts
index ddb4b178..40497ac3 100644
--- a/hooks/mutations/delegation/useCancelSentRequestToBeDelegate.ts
+++ b/hooks/mutations/delegation/useCancelSentRequestToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { sentRequestsToBeDelegateKey } from "constants/queryKeys";
+import { sentRequestsToBeDelegateKey } from "constant";
import { useHandleError, useUserContext } from "hooks";
import { DelegationEventT } from "types";
import { removeDelegate } from "web3";
@@ -12,9 +12,12 @@ export function useCancelSentRequestToBeDelegate() {
const { mutate, isLoading } = useMutation(removeDelegate, {
onError,
onSuccess: () => {
- queryClient.setQueryData([sentRequestsToBeDelegateKey, address], () => {
- return [];
- });
+ queryClient.setQueryData(
+ [sentRequestsToBeDelegateKey, address],
+ () => {
+ return [];
+ }
+ );
},
});
diff --git a/hooks/mutations/delegation/useIgnoreReceivedRequestToBeDelegate.ts b/hooks/mutations/delegation/useIgnoreReceivedRequestToBeDelegate.ts
index 70a4cf5e..efd5bc69 100644
--- a/hooks/mutations/delegation/useIgnoreReceivedRequestToBeDelegate.ts
+++ b/hooks/mutations/delegation/useIgnoreReceivedRequestToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { ignoredRequestToBeDelegateAddressesKey } from "constants/queryKeys";
+import { ignoredRequestToBeDelegateAddressesKey } from "constant";
import { getIgnoredRequestToBeDelegateAddressesFromStorage } from "helpers";
import { useHandleError, useUserContext } from "hooks";
@@ -16,7 +16,10 @@ export function useIgnoreReceivedRequestToBeDelegate() {
(oldIgnoredRequestToBeDelegateAddresses) => {
if (!oldIgnoredRequestToBeDelegateAddresses) return;
- const newIgnoredRequestToBeDelegateAddresses = [...oldIgnoredRequestToBeDelegateAddresses, delegatorAddress];
+ const newIgnoredRequestToBeDelegateAddresses = [
+ ...oldIgnoredRequestToBeDelegateAddresses,
+ delegatorAddress,
+ ];
return newIgnoredRequestToBeDelegateAddresses;
}
@@ -37,9 +40,14 @@ function ignoreReceivedRequestToBeDelegate({
userAddress: string;
delegatorAddress: string;
}) {
- const ignoredRequestToBeDelegateAddresses = getIgnoredRequestToBeDelegateAddressesFromStorage();
-
- if (!ignoredRequestToBeDelegateAddresses[userAddress]?.includes(delegatorAddress)) {
+ const ignoredRequestToBeDelegateAddresses =
+ getIgnoredRequestToBeDelegateAddressesFromStorage();
+
+ if (
+ !ignoredRequestToBeDelegateAddresses[userAddress]?.includes(
+ delegatorAddress
+ )
+ ) {
if (!ignoredRequestToBeDelegateAddresses[userAddress]) {
ignoredRequestToBeDelegateAddresses[userAddress] = [];
}
diff --git a/hooks/mutations/delegation/useSendRequestToBeDelegate.ts b/hooks/mutations/delegation/useSendRequestToBeDelegate.ts
index b591ed4c..f22ffa91 100644
--- a/hooks/mutations/delegation/useSendRequestToBeDelegate.ts
+++ b/hooks/mutations/delegation/useSendRequestToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { sentRequestsToBeDelegateKey, stakerDetailsKey } from "constants/queryKeys";
+import { sentRequestsToBeDelegateKey, stakerDetailsKey } from "constant";
import { useHandleError, useUserContext } from "hooks";
import { DelegationEventT, ErrorOriginT, StakerDetailsT } from "types";
import { setDelegate } from "web3";
@@ -12,21 +12,27 @@ export function useSendRequestToBeDelegate(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(setDelegate, {
onError,
onSuccess: ({ transactionHash }, { delegateAddress }) => {
- queryClient.setQueryData([stakerDetailsKey, address], (oldStakerDetails) => {
- if (!oldStakerDetails) return;
+ queryClient.setQueryData(
+ [stakerDetailsKey, address],
+ (oldStakerDetails) => {
+ if (!oldStakerDetails) return;
- return {
- ...oldStakerDetails,
- delegate: delegateAddress,
- };
- });
- queryClient.setQueryData([sentRequestsToBeDelegateKey, address], () => [
- {
- delegate: delegateAddress,
- delegator: address,
- transactionHash,
- },
- ]);
+ return {
+ ...oldStakerDetails,
+ delegate: delegateAddress,
+ };
+ }
+ );
+ queryClient.setQueryData(
+ [sentRequestsToBeDelegateKey, address],
+ () => [
+ {
+ delegate: delegateAddress,
+ delegator: address,
+ transactionHash,
+ },
+ ]
+ );
},
});
diff --git a/hooks/mutations/delegation/useTerminateRelationshipWithDelegate.ts b/hooks/mutations/delegation/useTerminateRelationshipWithDelegate.ts
index 5f6dd6a5..b5fcca73 100644
--- a/hooks/mutations/delegation/useTerminateRelationshipWithDelegate.ts
+++ b/hooks/mutations/delegation/useTerminateRelationshipWithDelegate.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { delegateToStakerKey, sentRequestsToBeDelegateKey } from "constants/queryKeys";
+import { delegateToStakerKey, sentRequestsToBeDelegateKey } from "constant";
import { zeroAddress } from "helpers";
import { useHandleError, useUserContext } from "hooks";
import { DelegationEventT } from "types";
@@ -13,8 +13,14 @@ export function useTerminateRelationshipWithDelegate() {
const { mutate, isLoading } = useMutation(removeDelegate, {
onError,
onSuccess: () => {
- queryClient.setQueryData([delegateToStakerKey, address], () => zeroAddress);
- queryClient.setQueryData([sentRequestsToBeDelegateKey, address], () => []);
+ queryClient.setQueryData(
+ [delegateToStakerKey, address],
+ () => zeroAddress
+ );
+ queryClient.setQueryData(
+ [sentRequestsToBeDelegateKey, address],
+ () => []
+ );
},
});
diff --git a/hooks/mutations/delegation/useTerminateRelationshipWithDelegator.ts b/hooks/mutations/delegation/useTerminateRelationshipWithDelegator.ts
index 9e30b26f..738a7f0f 100644
--- a/hooks/mutations/delegation/useTerminateRelationshipWithDelegator.ts
+++ b/hooks/mutations/delegation/useTerminateRelationshipWithDelegator.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { voterFromDelegateKey } from "constants/queryKeys";
+import { voterFromDelegateKey } from "constant";
import { useHandleError, useUserContext } from "hooks";
import { removeDelegator } from "web3";
@@ -11,7 +11,10 @@ export function useTerminateRelationshipWithDelegator() {
const { mutate, isLoading } = useMutation(removeDelegator, {
onError,
onSuccess: () => {
- queryClient.setQueryData([voterFromDelegateKey, address], () => address);
+ queryClient.setQueryData(
+ [voterFromDelegateKey, address],
+ () => address
+ );
},
});
diff --git a/hooks/mutations/staking/useApprove.ts b/hooks/mutations/staking/useApprove.ts
index 97526559..c431bb2e 100644
--- a/hooks/mutations/staking/useApprove.ts
+++ b/hooks/mutations/staking/useApprove.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { tokenAllowanceKey } from "constants/queryKeys";
+import { tokenAllowanceKey } from "constant";
import { BigNumber } from "ethers";
import { formatTransactionError } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
@@ -13,12 +13,15 @@ export function useApprove(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(approve, {
onSuccess: (_data, { approveAmount }) => {
- queryClient.setQueryData([tokenAllowanceKey, address], (oldTokenAllowance) => {
- if (oldTokenAllowance === undefined) return;
+ queryClient.setQueryData(
+ [tokenAllowanceKey, address],
+ (oldTokenAllowance) => {
+ if (oldTokenAllowance === undefined) return;
- const newTokenAllowance = oldTokenAllowance.add(approveAmount);
- return newTokenAllowance;
- });
+ const newTokenAllowance = oldTokenAllowance.add(approveAmount);
+ return newTokenAllowance;
+ }
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/staking/useExecuteUnstake.ts b/hooks/mutations/staking/useExecuteUnstake.ts
index b18178ff..6d3b72ff 100644
--- a/hooks/mutations/staking/useExecuteUnstake.ts
+++ b/hooks/mutations/staking/useExecuteUnstake.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { stakerDetailsKey, unstakedBalanceKey } from "constants/queryKeys";
+import { stakerDetailsKey, unstakedBalanceKey } from "constant";
import { BigNumber } from "ethers";
import { formatTransactionError } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
@@ -18,30 +18,44 @@ export function useExecuteUnstake(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(executeUnstake, {
onSuccess: () => {
- queryClient.setQueryData([unstakedBalanceKey, address], (oldUnstakedBalance) => {
- const oldStakerDetails = queryClient.getQueryData([stakerDetailsKey]);
-
- if (oldStakerDetails === undefined || oldUnstakedBalance === undefined) return;
-
- const newUnstakedBalance = oldUnstakedBalance.add(oldStakerDetails.pendingUnstake);
-
- return newUnstakedBalance;
- });
-
- queryClient.setQueryData([stakerDetailsKey, address], (oldStakerDetails) => {
- if (!oldStakerDetails) return;
- const newStakedBalance = max(
- BigNumber.from(0),
- oldStakerDetails.stakedBalance.sub(oldStakerDetails.pendingUnstake)
- );
- return {
- ...oldStakerDetails,
- stakedBalance: newStakedBalance,
- pendingUnstake: BigNumber.from(0),
- canUnstakeTime: undefined,
- unstakeRequestTime: undefined,
- };
- });
+ queryClient.setQueryData(
+ [unstakedBalanceKey, address],
+ (oldUnstakedBalance) => {
+ const oldStakerDetails = queryClient.getQueryData([
+ stakerDetailsKey,
+ ]);
+
+ if (
+ oldStakerDetails === undefined ||
+ oldUnstakedBalance === undefined
+ )
+ return;
+
+ const newUnstakedBalance = oldUnstakedBalance.add(
+ oldStakerDetails.pendingUnstake
+ );
+
+ return newUnstakedBalance;
+ }
+ );
+
+ queryClient.setQueryData(
+ [stakerDetailsKey, address],
+ (oldStakerDetails) => {
+ if (!oldStakerDetails) return;
+ const newStakedBalance = max(
+ BigNumber.from(0),
+ oldStakerDetails.stakedBalance.sub(oldStakerDetails.pendingUnstake)
+ );
+ return {
+ ...oldStakerDetails,
+ stakedBalance: newStakedBalance,
+ pendingUnstake: BigNumber.from(0),
+ canUnstakeTime: undefined,
+ unstakeRequestTime: undefined,
+ };
+ }
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/staking/useRequestUnstake.ts b/hooks/mutations/staking/useRequestUnstake.ts
index 0030c376..f2ca80e5 100644
--- a/hooks/mutations/staking/useRequestUnstake.ts
+++ b/hooks/mutations/staking/useRequestUnstake.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { stakerDetailsKey, unstakeCoolDownKey } from "constants/queryKeys";
+import { stakerDetailsKey, unstakeCoolDownKey } from "constant";
import { formatTransactionError, getCanUnstakeTime } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
import { ErrorOriginT, StakerDetailsT } from "types";
@@ -12,23 +12,36 @@ export function useRequestUnstake(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(requestUnstake, {
onSuccess: (_data, { unstakeAmount }) => {
- queryClient.setQueryData([stakerDetailsKey, address], (oldStakerDetails) => {
- if (oldStakerDetails === undefined) return;
+ queryClient.setQueryData(
+ [stakerDetailsKey, address],
+ (oldStakerDetails) => {
+ if (oldStakerDetails === undefined) return;
- const unstakeCoolDown = queryClient.getQueryData<{ unstakeCoolDown: number }>([unstakeCoolDownKey]);
+ const unstakeCoolDown = queryClient.getQueryData<{
+ unstakeCoolDown: number;
+ }>([unstakeCoolDownKey]);
- if (unstakeCoolDown === undefined || unstakeCoolDown.unstakeCoolDown === undefined) return;
+ if (
+ unstakeCoolDown === undefined ||
+ unstakeCoolDown.unstakeCoolDown === undefined
+ )
+ return;
- const newUnstakedBalance = oldStakerDetails.stakedBalance.sub(unstakeAmount);
+ const newUnstakedBalance =
+ oldStakerDetails.stakedBalance.sub(unstakeAmount);
- return {
- ...oldStakerDetails,
- stakedBalance: newUnstakedBalance,
- pendingUnstake: unstakeAmount,
- unstakeRequestTime: new Date(),
- canUnstakeTime: getCanUnstakeTime(new Date(), unstakeCoolDown.unstakeCoolDown),
- };
- });
+ return {
+ ...oldStakerDetails,
+ stakedBalance: newUnstakedBalance,
+ pendingUnstake: unstakeAmount,
+ unstakeRequestTime: new Date(),
+ canUnstakeTime: getCanUnstakeTime(
+ new Date(),
+ unstakeCoolDown.unstakeCoolDown
+ ),
+ };
+ }
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/staking/useStake.ts b/hooks/mutations/staking/useStake.ts
index 07fd9b1e..f192b533 100644
--- a/hooks/mutations/staking/useStake.ts
+++ b/hooks/mutations/staking/useStake.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { stakerDetailsKey, unstakedBalanceKey } from "constants/queryKeys";
+import { stakerDetailsKey, unstakedBalanceKey } from "constant";
import { BigNumber } from "ethers";
import { formatTransactionError } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
@@ -13,24 +13,31 @@ export function useStake(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(stake, {
onSuccess: (_data, { stakeAmount }) => {
- queryClient.setQueryData([stakerDetailsKey, address], (oldStakerDetails) => {
- if (oldStakerDetails === undefined) return;
+ queryClient.setQueryData(
+ [stakerDetailsKey, address],
+ (oldStakerDetails) => {
+ if (oldStakerDetails === undefined) return;
- const newStakedBalance = oldStakerDetails.stakedBalance.add(stakeAmount);
+ const newStakedBalance =
+ oldStakerDetails.stakedBalance.add(stakeAmount);
- return {
- ...oldStakerDetails,
- stakedBalance: newStakedBalance,
- };
- });
+ return {
+ ...oldStakerDetails,
+ stakedBalance: newStakedBalance,
+ };
+ }
+ );
- queryClient.setQueryData([unstakedBalanceKey, address], (oldUnstakedBalance) => {
- if (oldUnstakedBalance === undefined) return;
+ queryClient.setQueryData(
+ [unstakedBalanceKey, address],
+ (oldUnstakedBalance) => {
+ if (oldUnstakedBalance === undefined) return;
- const newUnstakedBalance = oldUnstakedBalance.sub(stakeAmount);
+ const newUnstakedBalance = oldUnstakedBalance.sub(stakeAmount);
- return newUnstakedBalance;
- });
+ return newUnstakedBalance;
+ }
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/staking/useWithdrawAndRestake.ts b/hooks/mutations/staking/useWithdrawAndRestake.ts
index f571fd04..32345c7c 100644
--- a/hooks/mutations/staking/useWithdrawAndRestake.ts
+++ b/hooks/mutations/staking/useWithdrawAndRestake.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { outstandingRewardsKey, stakerDetailsKey } from "constants/queryKeys";
+import { outstandingRewardsKey, stakerDetailsKey } from "constant";
import { BigNumber } from "ethers";
import { formatTransactionError } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
@@ -13,20 +13,33 @@ export function useWithdrawAndRestake(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(withdrawAndRestake, {
onSuccess: () => {
- queryClient.setQueryData([stakerDetailsKey, address], (oldStakerDetails) => {
- const outstandingRewards = queryClient.getQueryData([outstandingRewardsKey]);
+ queryClient.setQueryData(
+ [stakerDetailsKey, address],
+ (oldStakerDetails) => {
+ const outstandingRewards = queryClient.getQueryData([
+ outstandingRewardsKey,
+ ]);
- if (outstandingRewards === undefined || oldStakerDetails === undefined) return;
+ if (
+ outstandingRewards === undefined ||
+ oldStakerDetails === undefined
+ )
+ return;
- const newStakedBalance = oldStakerDetails.stakedBalance.add(outstandingRewards);
+ const newStakedBalance =
+ oldStakerDetails.stakedBalance.add(outstandingRewards);
- return {
- ...oldStakerDetails,
- stakedBalance: newStakedBalance,
- };
- });
+ return {
+ ...oldStakerDetails,
+ stakedBalance: newStakedBalance,
+ };
+ }
+ );
- queryClient.setQueryData([outstandingRewardsKey, address], () => BigNumber.from(0));
+ queryClient.setQueryData(
+ [outstandingRewardsKey, address],
+ () => BigNumber.from(0)
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/staking/useWithdrawRewards.ts b/hooks/mutations/staking/useWithdrawRewards.ts
index 353a58b4..cae01810 100644
--- a/hooks/mutations/staking/useWithdrawRewards.ts
+++ b/hooks/mutations/staking/useWithdrawRewards.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { outstandingRewardsKey, unstakedBalanceKey } from "constants/queryKeys";
+import { outstandingRewardsKey, unstakedBalanceKey } from "constant";
import { BigNumber } from "ethers";
import { formatTransactionError } from "helpers";
import { useAccountDetails, useHandleError } from "hooks";
@@ -13,17 +13,29 @@ export function useWithdrawRewards(errorOrigin?: ErrorOriginT) {
const { mutate, isLoading } = useMutation(withdrawRewards, {
onSuccess: () => {
- queryClient.setQueryData([unstakedBalanceKey, address], (oldUnstakedBalance) => {
- const outstandingRewards = queryClient.getQueryData([outstandingRewardsKey]);
+ queryClient.setQueryData(
+ [unstakedBalanceKey, address],
+ (oldUnstakedBalance) => {
+ const outstandingRewards = queryClient.getQueryData([
+ outstandingRewardsKey,
+ ]);
- if (outstandingRewards === undefined || oldUnstakedBalance === undefined) return;
+ if (
+ outstandingRewards === undefined ||
+ oldUnstakedBalance === undefined
+ )
+ return;
- const newUnstakedBalance = oldUnstakedBalance.add(outstandingRewards);
+ const newUnstakedBalance = oldUnstakedBalance.add(outstandingRewards);
- return newUnstakedBalance;
- });
+ return newUnstakedBalance;
+ }
+ );
- queryClient.setQueryData([outstandingRewardsKey, address], () => BigNumber.from(0));
+ queryClient.setQueryData(
+ [outstandingRewardsKey, address],
+ () => BigNumber.from(0)
+ );
},
onError(error: unknown) {
onError(formatTransactionError(error));
diff --git a/hooks/mutations/votes/useCommitVotes.ts b/hooks/mutations/votes/useCommitVotes.ts
index e120b1d0..cb05052f 100644
--- a/hooks/mutations/votes/useCommitVotes.ts
+++ b/hooks/mutations/votes/useCommitVotes.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { committedVotesKey, encryptedVotesKey } from "constants/queryKeys";
+import { committedVotesKey, encryptedVotesKey } from "constant";
import { useAccountDetails, useHandleError, useVoteTimingContext } from "hooks";
import { EncryptedVotesByKeyT, VoteExistsByKeyT } from "types";
import { commitVotes } from "web3";
@@ -12,25 +12,31 @@ export function useCommitVotes() {
const { mutate, isLoading } = useMutation(commitVotes, {
onSuccess: (_data, { formattedVotes }) => {
- queryClient.setQueryData([committedVotesKey, address, roundId], (oldCommittedVotes) => {
- const newCommittedVotes = { ...oldCommittedVotes };
+ queryClient.setQueryData(
+ [committedVotesKey, address, roundId],
+ (oldCommittedVotes) => {
+ const newCommittedVotes = { ...oldCommittedVotes };
- for (const { uniqueKey } of formattedVotes) {
- newCommittedVotes[uniqueKey] = true;
+ for (const { uniqueKey } of formattedVotes) {
+ newCommittedVotes[uniqueKey] = true;
+ }
+
+ return newCommittedVotes;
}
+ );
- return newCommittedVotes;
- });
+ queryClient.setQueryData(
+ [encryptedVotesKey, address, roundId],
+ (oldEncryptedVotes) => {
+ const newEncryptedVotes = { ...oldEncryptedVotes };
- queryClient.setQueryData([encryptedVotesKey, address, roundId], (oldEncryptedVotes) => {
- const newEncryptedVotes = { ...oldEncryptedVotes };
+ for (const { uniqueKey, encryptedVote } of formattedVotes) {
+ newEncryptedVotes[uniqueKey] = encryptedVote;
+ }
- for (const { uniqueKey, encryptedVote } of formattedVotes) {
- newEncryptedVotes[uniqueKey] = encryptedVote;
+ return newEncryptedVotes;
}
-
- return newEncryptedVotes;
- });
+ );
},
onError,
});
diff --git a/hooks/mutations/votes/useRevealVotes.ts b/hooks/mutations/votes/useRevealVotes.ts
index 16e6f232..53cb8332 100644
--- a/hooks/mutations/votes/useRevealVotes.ts
+++ b/hooks/mutations/votes/useRevealVotes.ts
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { revealedVotesKey } from "constants/queryKeys";
+import { revealedVotesKey } from "constant";
import { useAccountDetails, useHandleError, useVoteTimingContext } from "hooks";
import { VoteExistsByKeyT } from "types";
import { revealVotes } from "web3";
@@ -12,15 +12,18 @@ export function useRevealVotes() {
const { mutate, isLoading } = useMutation(revealVotes, {
onSuccess: (_data, { votesToReveal }) => {
- queryClient.setQueryData([revealedVotesKey, address, roundId], (oldRevealedVotes) => {
- const newRevealedVotes = { ...oldRevealedVotes };
+ queryClient.setQueryData(
+ [revealedVotesKey, address, roundId],
+ (oldRevealedVotes) => {
+ const newRevealedVotes = { ...oldRevealedVotes };
- for (const { uniqueKey } of votesToReveal) {
- newRevealedVotes[uniqueKey] = true;
- }
+ for (const { uniqueKey } of votesToReveal) {
+ newRevealedVotes[uniqueKey] = true;
+ }
- return newRevealedVotes;
- });
+ return newRevealedVotes;
+ }
+ );
},
onError,
});
diff --git a/hooks/queries/delegation/useCommittedVotesForDelegator.ts b/hooks/queries/delegation/useCommittedVotesForDelegator.ts
index f67cd8f4..ca84b603 100644
--- a/hooks/queries/delegation/useCommittedVotesForDelegator.ts
+++ b/hooks/queries/delegation/useCommittedVotesForDelegator.ts
@@ -1,6 +1,12 @@
import { useQuery } from "@tanstack/react-query";
-import { committedVotesForDelegatorKey } from "constants/queryKeys";
-import { useContractsContext, useDelegationContext, useHandleError, useUserContext, useVoteTimingContext } from "hooks";
+import { committedVotesForDelegatorKey } from "constant";
+import {
+ useContractsContext,
+ useDelegationContext,
+ useHandleError,
+ useUserContext,
+ useVoteTimingContext,
+} from "hooks";
import { getCommittedVotes } from "web3";
export function useCommittedVotesForDelegator() {
diff --git a/hooks/queries/delegation/useDelegateToStaker.ts b/hooks/queries/delegation/useDelegateToStaker.ts
index 85c91019..172d6636 100644
--- a/hooks/queries/delegation/useDelegateToStaker.ts
+++ b/hooks/queries/delegation/useDelegateToStaker.ts
@@ -1,7 +1,12 @@
import { useQuery } from "@tanstack/react-query";
-import { delegateToStakerKey } from "constants/queryKeys";
+import { delegateToStakerKey } from "constant";
import { zeroAddress } from "helpers";
-import { useContractsContext, useHandleError, useStakerDetails, useUserContext } from "hooks";
+import {
+ useContractsContext,
+ useHandleError,
+ useStakerDetails,
+ useUserContext,
+} from "hooks";
import { getDelegateToStaker } from "web3";
export function useDelegateToStaker() {
diff --git a/hooks/queries/delegation/useDelegatorSetEventsForDelegate.ts b/hooks/queries/delegation/useDelegatorSetEventsForDelegate.ts
index ac7d3045..65d21daa 100644
--- a/hooks/queries/delegation/useDelegatorSetEventsForDelegate.ts
+++ b/hooks/queries/delegation/useDelegatorSetEventsForDelegate.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { delegatorSetEventForDelegateKey } from "constants/queryKeys";
+import { delegatorSetEventForDelegateKey } from "constant";
import { useContractsContext, useHandleError, useUserContext } from "hooks";
import { getDelegatorSetEvents } from "web3";
diff --git a/hooks/queries/delegation/useDelegatorSetEventsForDelegator.ts b/hooks/queries/delegation/useDelegatorSetEventsForDelegator.ts
index 0172cc26..327080ae 100644
--- a/hooks/queries/delegation/useDelegatorSetEventsForDelegator.ts
+++ b/hooks/queries/delegation/useDelegatorSetEventsForDelegator.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { delegatorSetEventsForDelegatorKey } from "constants/queryKeys";
+import { delegatorSetEventsForDelegatorKey } from "constant";
import { useContractsContext, useHandleError, useUserContext } from "hooks";
import { getDelegatorSetEvents } from "web3";
diff --git a/hooks/queries/delegation/useIgnoredRequestToBeDelegateAddresses.ts b/hooks/queries/delegation/useIgnoredRequestToBeDelegateAddresses.ts
index 86468fa6..c3dba593 100644
--- a/hooks/queries/delegation/useIgnoredRequestToBeDelegateAddresses.ts
+++ b/hooks/queries/delegation/useIgnoredRequestToBeDelegateAddresses.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { ignoredRequestToBeDelegateAddressesKey } from "constants/queryKeys";
+import { ignoredRequestToBeDelegateAddressesKey } from "constant";
import { useHandleError, useUserContext } from "hooks";
import { getIgnoredRequestToBeDelegateAddresses } from "web3";
diff --git a/hooks/queries/delegation/useReceivedRequestsToBeDelegate.ts b/hooks/queries/delegation/useReceivedRequestsToBeDelegate.ts
index d0c3c8a6..d4b1c7e2 100644
--- a/hooks/queries/delegation/useReceivedRequestsToBeDelegate.ts
+++ b/hooks/queries/delegation/useReceivedRequestsToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { receivedRequestsToBeDelegateKey } from "constants/queryKeys";
+import { receivedRequestsToBeDelegateKey } from "constant";
import { useContractsContext, useHandleError, useUserContext } from "hooks";
import { getDelegateSetEvents } from "web3";
diff --git a/hooks/queries/delegation/useSentRequestsToBeDelegate.ts b/hooks/queries/delegation/useSentRequestsToBeDelegate.ts
index d4ce9859..4a9e98f4 100644
--- a/hooks/queries/delegation/useSentRequestsToBeDelegate.ts
+++ b/hooks/queries/delegation/useSentRequestsToBeDelegate.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { sentRequestsToBeDelegateKey } from "constants/queryKeys";
+import { sentRequestsToBeDelegateKey } from "constant";
import { useContractsContext, useHandleError, useUserContext } from "hooks";
import { getDelegateSetEvents } from "web3";
diff --git a/hooks/queries/delegation/useVoterFromDelegate.ts b/hooks/queries/delegation/useVoterFromDelegate.ts
index 508f69ad..4c28f5b9 100644
--- a/hooks/queries/delegation/useVoterFromDelegate.ts
+++ b/hooks/queries/delegation/useVoterFromDelegate.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { voterFromDelegateKey } from "constants/queryKeys";
+import { voterFromDelegateKey } from "constant";
import { useContractsContext, useUserContext } from "hooks";
import { getVoterFromDelegate } from "web3";
@@ -7,10 +7,14 @@ export function useVoterFromDelegate() {
const { voting } = useContractsContext();
const { address } = useUserContext();
- const queryResult = useQuery([voterFromDelegateKey, address], () => getVoterFromDelegate(voting, address), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- });
+ const queryResult = useQuery(
+ [voterFromDelegateKey, address],
+ () => getVoterFromDelegate(voting, address),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/staking/useOutstandingRewards.ts b/hooks/queries/staking/useOutstandingRewards.ts
index 0ef3afc4..98eb05fd 100644
--- a/hooks/queries/staking/useOutstandingRewards.ts
+++ b/hooks/queries/staking/useOutstandingRewards.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { outstandingRewardsKey } from "constants/queryKeys";
+import { outstandingRewardsKey } from "constant";
import { BigNumber } from "ethers";
import { useAccountDetails, useContractsContext, useHandleError } from "hooks";
import { getOutstandingRewards } from "web3";
@@ -9,12 +9,16 @@ export function useOutstandingRewards() {
const { address } = useAccountDetails();
const onError = useHandleError();
- const queryResult = useQuery([outstandingRewardsKey, address], () => getOutstandingRewards(voting, address), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- initialData: BigNumber.from(0),
- onError,
- });
+ const queryResult = useQuery(
+ [outstandingRewardsKey, address],
+ () => getOutstandingRewards(voting, address),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ initialData: BigNumber.from(0),
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/staking/useStakerDetails.ts b/hooks/queries/staking/useStakerDetails.ts
index d0e0fbb4..bd3b5cfe 100644
--- a/hooks/queries/staking/useStakerDetails.ts
+++ b/hooks/queries/staking/useStakerDetails.ts
@@ -1,8 +1,13 @@
import { useQuery } from "@tanstack/react-query";
-import { stakerDetailsKey } from "constants/queryKeys";
+import { stakerDetailsKey } from "constant";
import { BigNumber } from "ethers";
import { zeroAddress } from "helpers";
-import { useAccountDetails, useContractsContext, useDelegationContext, useHandleError } from "hooks";
+import {
+ useAccountDetails,
+ useContractsContext,
+ useDelegationContext,
+ useHandleError,
+} from "hooks";
import { getStakerDetails } from "web3";
export function useStakerDetails() {
@@ -14,20 +19,25 @@ export function useStakerDetails() {
const status = getDelegationStatus();
const delegatorAddress = getDelegatorAddress();
- const addressToQuery = status === "delegate" && delegatorAddress ? delegatorAddress : address;
+ const addressToQuery =
+ status === "delegate" && delegatorAddress ? delegatorAddress : address;
- const queryResult = useQuery([stakerDetailsKey, address], () => getStakerDetails(voting, addressToQuery), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- initialData: {
- stakedBalance: BigNumber.from(0),
- pendingUnstake: BigNumber.from(0),
- unstakeRequestTime: new Date(0),
- canUnstakeTime: new Date(0),
- delegate: zeroAddress,
- },
- onError,
- });
+ const queryResult = useQuery(
+ [stakerDetailsKey, address],
+ () => getStakerDetails(voting, addressToQuery),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ initialData: {
+ stakedBalance: BigNumber.from(0),
+ pendingUnstake: BigNumber.from(0),
+ unstakeRequestTime: new Date(0),
+ canUnstakeTime: new Date(0),
+ delegate: zeroAddress,
+ },
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/staking/useTokenAllowance.ts b/hooks/queries/staking/useTokenAllowance.ts
index 6e828b92..91eb9f7a 100644
--- a/hooks/queries/staking/useTokenAllowance.ts
+++ b/hooks/queries/staking/useTokenAllowance.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { tokenAllowanceKey } from "constants/queryKeys";
+import { tokenAllowanceKey } from "constant";
import { BigNumber } from "ethers";
import { useAccountDetails, useContractsContext, useHandleError } from "hooks";
import { getTokenAllowance } from "web3";
@@ -9,12 +9,16 @@ export function useTokenAllowance() {
const { address } = useAccountDetails();
const onError = useHandleError();
- const queryResult = useQuery([tokenAllowanceKey, address], () => getTokenAllowance(votingToken, address), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- initialData: BigNumber.from(0),
- onError,
- });
+ const queryResult = useQuery(
+ [tokenAllowanceKey, address],
+ () => getTokenAllowance(votingToken, address),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ initialData: BigNumber.from(0),
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/staking/useUnstakeCoolDown.ts b/hooks/queries/staking/useUnstakeCoolDown.ts
index 8f8c47dc..6b067ccd 100644
--- a/hooks/queries/staking/useUnstakeCoolDown.ts
+++ b/hooks/queries/staking/useUnstakeCoolDown.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { unstakeCoolDownKey } from "constants/queryKeys";
+import { unstakeCoolDownKey } from "constant";
import { useContractsContext, useHandleError } from "hooks";
import { getUnstakeCoolDown } from "web3";
@@ -7,12 +7,16 @@ export function useUnstakeCoolDown() {
const { voting } = useContractsContext();
const onError = useHandleError();
// only need to fetch this one time
- const queryResult = useQuery([unstakeCoolDownKey], () => getUnstakeCoolDown(voting), {
- initialData: {
- unstakeCoolDown: 0,
- },
- onError,
- });
+ const queryResult = useQuery(
+ [unstakeCoolDownKey],
+ () => getUnstakeCoolDown(voting),
+ {
+ initialData: {
+ unstakeCoolDown: 0,
+ },
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/staking/useUnstakedBalance.ts b/hooks/queries/staking/useUnstakedBalance.ts
index f3a8b57b..91c96f64 100644
--- a/hooks/queries/staking/useUnstakedBalance.ts
+++ b/hooks/queries/staking/useUnstakedBalance.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { unstakedBalanceKey } from "constants/queryKeys";
+import { unstakedBalanceKey } from "constant";
import { useAccountDetails, useContractsContext, useHandleError } from "hooks";
import { getUnstakedBalance } from "web3";
@@ -8,11 +8,15 @@ export function useUnstakedBalance() {
const { address } = useAccountDetails();
const onError = useHandleError();
- const queryResult = useQuery([unstakedBalanceKey, address], () => getUnstakedBalance(votingToken, address), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- onError,
- });
+ const queryResult = useQuery(
+ [unstakedBalanceKey, address],
+ () => getUnstakedBalance(votingToken, address),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/user/useUserVotingAndStakingDetails.ts b/hooks/queries/user/useUserVotingAndStakingDetails.ts
index e8328541..fcc5cb86 100644
--- a/hooks/queries/user/useUserVotingAndStakingDetails.ts
+++ b/hooks/queries/user/useUserVotingAndStakingDetails.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { userDataKey } from "constants/queryKeys";
+import { userDataKey } from "constant";
import { BigNumber } from "ethers";
import { getUserData } from "graph";
import { useAccountDetails, useHandleError } from "hooks";
@@ -8,21 +8,25 @@ export function useUserVotingAndStakingDetails() {
const { address } = useAccountDetails();
const onError = useHandleError();
- const queryResult = useQuery([userDataKey, address], () => getUserData(address), {
- enabled: !!address,
- refetchInterval: (data) => (data ? false : 100),
- initialData: {
- apr: BigNumber.from(0),
- countReveals: BigNumber.from(0),
- countNoVotes: BigNumber.from(0),
- countWrongVotes: BigNumber.from(0),
- countCorrectVotes: BigNumber.from(0),
- cumulativeCalculatedSlash: BigNumber.from(0),
- cumulativeCalculatedSlashPercentage: BigNumber.from(0),
- voteHistoryByKey: {},
- },
- onError,
- });
+ const queryResult = useQuery(
+ [userDataKey, address],
+ () => getUserData(address),
+ {
+ enabled: !!address,
+ refetchInterval: (data) => (data ? false : 100),
+ initialData: {
+ apr: BigNumber.from(0),
+ countReveals: BigNumber.from(0),
+ countNoVotes: BigNumber.from(0),
+ countWrongVotes: BigNumber.from(0),
+ countCorrectVotes: BigNumber.from(0),
+ cumulativeCalculatedSlash: BigNumber.from(0),
+ cumulativeCalculatedSlashPercentage: BigNumber.from(0),
+ voteHistoryByKey: {},
+ },
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/votes/useActiveVotes.ts b/hooks/queries/votes/useActiveVotes.ts
index 3d8dbedf..7a671d2d 100644
--- a/hooks/queries/votes/useActiveVotes.ts
+++ b/hooks/queries/votes/useActiveVotes.ts
@@ -1,6 +1,10 @@
import { useQuery } from "@tanstack/react-query";
-import { activeVotesKey } from "constants/queryKeys";
-import { useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { activeVotesKey } from "constant";
+import {
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getActiveVotes } from "web3";
export function useActiveVotes() {
@@ -8,11 +12,15 @@ export function useActiveVotes() {
const { roundId } = useVoteTimingContext();
const onError = useHandleError();
- const queryResult = useQuery([activeVotesKey, roundId], () => getActiveVotes(voting), {
- refetchInterval: (data) => (data ? false : 100),
- initialData: {},
- onError,
- });
+ const queryResult = useQuery(
+ [activeVotesKey, roundId],
+ () => getActiveVotes(voting),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ initialData: {},
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/votes/useCommittedVotes.ts b/hooks/queries/votes/useCommittedVotes.ts
index 7f1aedbc..2dafbed7 100644
--- a/hooks/queries/votes/useCommittedVotes.ts
+++ b/hooks/queries/votes/useCommittedVotes.ts
@@ -1,6 +1,11 @@
import { useQuery } from "@tanstack/react-query";
-import { committedVotesKey } from "constants/queryKeys";
-import { useAccountDetails, useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { committedVotesKey } from "constant";
+import {
+ useAccountDetails,
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getCommittedVotes } from "web3";
export function useCommittedVotes() {
diff --git a/hooks/queries/votes/useContentfulData.ts b/hooks/queries/votes/useContentfulData.ts
index 17ffbbd2..99dc865a 100644
--- a/hooks/queries/votes/useContentfulData.ts
+++ b/hooks/queries/votes/useContentfulData.ts
@@ -1,7 +1,12 @@
import { useQuery } from "@tanstack/react-query";
-import { contentfulDataKey } from "constants/queryKeys";
+import { contentfulDataKey } from "constant";
import * as contentful from "contentful";
-import { useActiveVotes, useHandleError, usePastVotes, useUpcomingVotes } from "hooks";
+import {
+ useActiveVotes,
+ useHandleError,
+ usePastVotes,
+ useUpcomingVotes,
+} from "hooks";
import { ContentfulDataByKeyT, ContentfulDataT, UniqueKeyT } from "types";
const space = process.env.NEXT_PUBLIC_CONTENTFUL_SPACE_ID ?? "";
@@ -12,7 +17,9 @@ const contentfulClient = contentful.createClient({
accessToken,
});
-async function getContentfulData(adminProposalNumbersByKey: Record) {
+async function getContentfulData(
+ adminProposalNumbersByKey: Record
+) {
const adminProposalNumbers = Object.values(adminProposalNumbersByKey);
if (adminProposalNumbers.length === 0) return {};
@@ -48,7 +55,11 @@ export function useContentfulData() {
const adminProposalNumbersByKey: Record = {};
- for (const [uniqueKey, { decodedIdentifier }] of Object.entries({ ...activeVotes, ...upcomingVotes, ...pastVotes })) {
+ for (const [uniqueKey, { decodedIdentifier }] of Object.entries({
+ ...activeVotes,
+ ...upcomingVotes,
+ ...pastVotes,
+ })) {
const adminProposalNumber = getAdminProposalNumber(decodedIdentifier);
if (adminProposalNumber) {
adminProposalNumbersByKey[uniqueKey] = adminProposalNumber;
diff --git a/hooks/queries/votes/useDecryptedVotes.ts b/hooks/queries/votes/useDecryptedVotes.ts
index 43fb47cc..d87e8b7e 100644
--- a/hooks/queries/votes/useDecryptedVotes.ts
+++ b/hooks/queries/votes/useDecryptedVotes.ts
@@ -1,8 +1,17 @@
import { useQuery } from "@tanstack/react-query";
-import { decryptedVotesKey } from "constants/queryKeys";
+import { decryptedVotesKey } from "constant";
import { decryptMessage } from "helpers";
-import { useAccountDetails, useEncryptedVotes, useHandleError, useWalletContext } from "hooks";
-import { DecryptedVotesByKeyT, DecryptedVoteT, EncryptedVotesByKeyT } from "types";
+import {
+ useAccountDetails,
+ useEncryptedVotes,
+ useHandleError,
+ useWalletContext,
+} from "hooks";
+import {
+ DecryptedVotesByKeyT,
+ DecryptedVoteT,
+ EncryptedVotesByKeyT,
+} from "types";
export function useDecryptedVotes() {
const { address } = useAccountDetails();
@@ -24,15 +33,23 @@ export function useDecryptedVotes() {
return queryResult;
}
-async function decryptVotes(privateKey: string | undefined, encryptedVotes: EncryptedVotesByKeyT) {
+async function decryptVotes(
+ privateKey: string | undefined,
+ encryptedVotes: EncryptedVotesByKeyT
+) {
const decryptedVotes: DecryptedVotesByKeyT = {};
if (!privateKey || Object.keys(encryptedVotes).length === 0) return {};
- for await (const [uniqueKey, encryptedVote] of Object.entries(encryptedVotes)) {
+ for await (const [uniqueKey, encryptedVote] of Object.entries(
+ encryptedVotes
+ )) {
let decryptedVote: DecryptedVoteT;
if (encryptedVote && privateKey) {
- const decryptedVoteString = await decryptMessage(privateKey, encryptedVote);
+ const decryptedVoteString = await decryptMessage(
+ privateKey,
+ encryptedVote
+ );
decryptedVote = JSON.parse(decryptedVoteString) as DecryptedVoteT;
if (decryptedVote) {
diff --git a/hooks/queries/votes/useEncryptedVotes.ts b/hooks/queries/votes/useEncryptedVotes.ts
index 96f0537d..2bdd9e7d 100644
--- a/hooks/queries/votes/useEncryptedVotes.ts
+++ b/hooks/queries/votes/useEncryptedVotes.ts
@@ -1,6 +1,11 @@
import { useQuery } from "@tanstack/react-query";
-import { encryptedVotesKey } from "constants/queryKeys";
-import { useAccountDetails, useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { encryptedVotesKey } from "constant";
+import {
+ useAccountDetails,
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getEncryptedVotes } from "web3";
export function useEncryptedVotes() {
diff --git a/hooks/queries/votes/useHasActiveVotes.ts b/hooks/queries/votes/useHasActiveVotes.ts
index f56e5236..af5318f2 100644
--- a/hooks/queries/votes/useHasActiveVotes.ts
+++ b/hooks/queries/votes/useHasActiveVotes.ts
@@ -1,6 +1,10 @@
import { useQuery } from "@tanstack/react-query";
-import { hasActiveVotesKey } from "constants/queryKeys";
-import { useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { hasActiveVotesKey } from "constant";
+import {
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getHasActiveVotes } from "web3";
export function useHasActiveVotes() {
@@ -8,10 +12,14 @@ export function useHasActiveVotes() {
const { roundId } = useVoteTimingContext();
const onError = useHandleError();
- const queryResult = useQuery([hasActiveVotesKey, roundId], () => getHasActiveVotes(voting), {
- refetchInterval: (data) => (data ? false : 100),
- onError,
- });
+ const queryResult = useQuery(
+ [hasActiveVotesKey, roundId],
+ () => getHasActiveVotes(voting),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/votes/usePastVotes.ts b/hooks/queries/votes/usePastVotes.ts
index 145a62cc..54bdd676 100644
--- a/hooks/queries/votes/usePastVotes.ts
+++ b/hooks/queries/votes/usePastVotes.ts
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
-import { pastVotesKey } from "constants/queryKeys";
+import { pastVotesKey } from "constant";
import { getPastVotes } from "graph";
import { useHandleError, useVoteTimingContext } from "hooks";
diff --git a/hooks/queries/votes/useRevealedVotes.ts b/hooks/queries/votes/useRevealedVotes.ts
index 6e46e376..0622ece8 100644
--- a/hooks/queries/votes/useRevealedVotes.ts
+++ b/hooks/queries/votes/useRevealedVotes.ts
@@ -1,6 +1,11 @@
import { useQuery } from "@tanstack/react-query";
-import { revealedVotesKey } from "constants/queryKeys";
-import { useAccountDetails, useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { revealedVotesKey } from "constant";
+import {
+ useAccountDetails,
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getRevealedVotes } from "web3";
export function useRevealedVotes() {
@@ -9,12 +14,16 @@ export function useRevealedVotes() {
const { roundId } = useVoteTimingContext();
const onError = useHandleError();
- const queryResult = useQuery([revealedVotesKey, address, roundId], () => getRevealedVotes(voting, address, roundId), {
- refetchInterval: (data) => (data ? false : 100),
- enabled: !!address,
- initialData: {},
- onError,
- });
+ const queryResult = useQuery(
+ [revealedVotesKey, address, roundId],
+ () => getRevealedVotes(voting, address, roundId),
+ {
+ refetchInterval: (data) => (data ? false : 100),
+ enabled: !!address,
+ initialData: {},
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/votes/useUpcomingVotes.ts b/hooks/queries/votes/useUpcomingVotes.ts
index d1b1ee70..28f716a9 100644
--- a/hooks/queries/votes/useUpcomingVotes.ts
+++ b/hooks/queries/votes/useUpcomingVotes.ts
@@ -1,6 +1,10 @@
import { useQuery } from "@tanstack/react-query";
-import { upcomingVotesKey } from "constants/queryKeys";
-import { useContractsContext, useHandleError, useVoteTimingContext } from "hooks";
+import { upcomingVotesKey } from "constant";
+import {
+ useContractsContext,
+ useHandleError,
+ useVoteTimingContext,
+} from "hooks";
import { getUpcomingVotes } from "web3";
export function useUpcomingVotes() {
@@ -8,16 +12,20 @@ export function useUpcomingVotes() {
const { roundId } = useVoteTimingContext();
const onError = useHandleError();
- const queryResult = useQuery([upcomingVotesKey, roundId], () => getUpcomingVotes(voting, roundId), {
- refetchInterval(data) {
- return data ? false : 100;
- },
- initialData: {
- upcomingVotes: {},
- hasUpcomingVotes: false,
- },
- onError,
- });
+ const queryResult = useQuery(
+ [upcomingVotesKey, roundId],
+ () => getUpcomingVotes(voting, roundId),
+ {
+ refetchInterval(data) {
+ return data ? false : 100;
+ },
+ initialData: {
+ upcomingVotes: {},
+ hasUpcomingVotes: false,
+ },
+ onError,
+ }
+ );
return queryResult;
}
diff --git a/hooks/queries/votes/useVoteTransactionHashes.ts b/hooks/queries/votes/useVoteTransactionHashes.ts
index 9833ebd3..0a54a0dc 100644
--- a/hooks/queries/votes/useVoteTransactionHashes.ts
+++ b/hooks/queries/votes/useVoteTransactionHashes.ts
@@ -1,6 +1,12 @@
import { useQuery } from "@tanstack/react-query";
-import { voteTransactionHashesKey } from "constants/queryKeys";
-import { useActiveVotes, useContractsContext, useHandleError, usePastVotes, useUpcomingVotes } from "hooks";
+import { voteTransactionHashesKey } from "constant";
+import {
+ useActiveVotes,
+ useContractsContext,
+ useHandleError,
+ usePastVotes,
+ useUpcomingVotes,
+} from "hooks";
import { getVoteTransactionHashes } from "web3";
export function useVoteTransactionHashes() {
@@ -14,7 +20,12 @@ export function useVoteTransactionHashes() {
const queryResult = useQuery(
[voteTransactionHashesKey, activeVotes, upcomingVotes, pastVotes],
- () => getVoteTransactionHashes(voting, { ...activeVotes, ...upcomingVotes, ...pastVotes }),
+ () =>
+ getVoteTransactionHashes(voting, {
+ ...activeVotes,
+ ...upcomingVotes,
+ ...pastVotes,
+ }),
{
refetchInterval: (data) => (data ? false : 100),
initialData: {},
diff --git a/pages/_document.tsx b/pages/_document.tsx
index deac78a9..864b855a 100644
--- a/pages/_document.tsx
+++ b/pages/_document.tsx
@@ -1,4 +1,10 @@
-import Document, { DocumentContext, Html, Head, Main, NextScript } from "next/document";
+import Document, {
+ DocumentContext,
+ Html,
+ Head,
+ Main,
+ NextScript,
+} from "next/document";
import { ServerStyleSheet } from "styled-components";
export default class MyDocument extends Document {
@@ -13,10 +19,16 @@ export default class MyDocument extends Document {
try {
ctx.renderPage = () =>
- originalRenderPage({ enhanceApp: (App) => (props) => sheet.collectStyles() });
+ originalRenderPage({
+ enhanceApp: (App) => (props) =>
+ sheet.collectStyles(),
+ });
const initialProps = await Document.getInitialProps(ctx);
- return { ...initialProps, styles: [initialProps.styles, sheet.getStyleElement()] };
+ return {
+ ...initialProps,
+ styles: [initialProps.styles, sheet.getStyleElement()],
+ };
} finally {
sheet.seal();
}
@@ -54,7 +66,13 @@ export default class MyDocument extends Document {
type="font/woff2"
crossOrigin="anonymous"
/>
-
+
-
+
diff --git a/pages/api/_common.ts b/pages/api/_common.ts
index 93fb213b..7e035093 100644
--- a/pages/api/_common.ts
+++ b/pages/api/_common.ts
@@ -18,7 +18,20 @@ export function getNodeUrls(): { [key: string]: string } {
return JSON.parse(process.env.NODE_URLS);
}
-export async function constructContractOnChain(chainId: number, contractName: any) {
- console.log("getting", contractName, "on chain", chainId, await getAddress(contractName, chainId));
- return new Contract(await getAddress(contractName, chainId), getAbi(contractName), getProviderByChainId(chainId));
+export async function constructContractOnChain(
+ chainId: number,
+ contractName: any
+) {
+ console.log(
+ "getting",
+ contractName,
+ "on chain",
+ chainId,
+ await getAddress(contractName, chainId)
+ );
+ return new Contract(
+ await getAddress(contractName, chainId),
+ getAbi(contractName),
+ getProviderByChainId(chainId)
+ );
}
diff --git a/pages/api/augment-request.ts b/pages/api/augment-request.ts
index 4491ced1..973b8f8c 100644
--- a/pages/api/augment-request.ts
+++ b/pages/api/augment-request.ts
@@ -25,26 +25,46 @@ function getOoChainIds() {
return Object.keys(getNodeUrls()).map((z) => Number(z));
}
-function constructOoUiLink(txHash: string, chainId: number, oracleType: string) {
+function constructOoUiLink(
+ txHash: string,
+ chainId: number,
+ oracleType: string
+) {
return `https://oracle.umaproject.org/request?transactionHash=${txHash}&chainId=${chainId}&oracleType=${oracleType}`;
}
-async function constructOptimisticOraclesByChain(chainId: number): Promise<(Contract | null)[]> {
- const optimisticOracle = await constructContractOnChain(chainId, "OptimisticOracle");
- const optimisticOracleV2 = await constructContractOnChain(chainId, "OptimisticOracleV2");
+async function constructOptimisticOraclesByChain(
+ chainId: number
+): Promise<(Contract | null)[]> {
+ const optimisticOracle = await constructContractOnChain(
+ chainId,
+ "OptimisticOracle"
+ );
+ const optimisticOracleV2 = await constructContractOnChain(
+ chainId,
+ "OptimisticOracleV2"
+ );
// Only mainnet has a SkinnyOptimisticOracle so only construct it here. All other chains of interest have OOv1 and V2.
const skinnyOptimisticOracle =
- chainId == 1 ? await constructContractOnChain(chainId, "SkinnyOptimisticOracle") : null;
+ chainId == 1
+ ? await constructContractOnChain(chainId, "SkinnyOptimisticOracle")
+ : null;
return [optimisticOracle, optimisticOracleV2, skinnyOptimisticOracle];
}
-async function getOptimisticOraclePriceRequestEventsByChainId(chainId: number): Promise {
- const chainOptimisticOracles = await constructOptimisticOraclesByChain(chainId);
+async function getOptimisticOraclePriceRequestEventsByChainId(
+ chainId: number
+): Promise {
+ const chainOptimisticOracles = await constructOptimisticOraclesByChain(
+ chainId
+ );
const requests = await Promise.all(
chainOptimisticOracles.map((optimisticOracle) =>
- optimisticOracle ? optimisticOracle.queryFilter(optimisticOracle.filters.RequestPrice()) : null
+ optimisticOracle
+ ? optimisticOracle.queryFilter(optimisticOracle.filters.RequestPrice())
+ : null
)
);
@@ -66,19 +86,28 @@ async function getOptimisticOraclePriceRequestEventsByChainId(chainId: number):
async function getRequestTxFromL1RequestInformation(
l1Requests: Request[]
-): Promise<{ requestTransactionHash: string; chainId: number; oracleType: any }[]> {
+): Promise<
+ { requestTransactionHash: string; chainId: number; oracleType: any }[]
+> {
const ooChainIds = getOoChainIds();
const chainOoRequests = await Promise.all(
- ooChainIds.map((chainId) => getOptimisticOraclePriceRequestEventsByChainId(chainId))
+ ooChainIds.map((chainId) =>
+ getOptimisticOraclePriceRequestEventsByChainId(chainId)
+ )
);
- const ooRequestTxs: { requestTransactionHash: string; chainId: number; oracleType: any }[] = [];
+ const ooRequestTxs: {
+ requestTransactionHash: string;
+ chainId: number;
+ oracleType: any;
+ }[] = [];
l1Requests.forEach((l1Request) => {
let foundOoTx = { requestTransactionHash: "", chainId: 0, oracleType: "" };
chainOoRequests.forEach((_, ooChainId) => {
chainOoRequests[ooChainId].forEach((ooRequest) => {
if (
- l1Request.identifier.toLowerCase() == ooRequest.identifier.toLowerCase() &&
+ l1Request.identifier.toLowerCase() ==
+ ooRequest.identifier.toLowerCase() &&
l1Request.time == ooRequest.time
) {
foundOoTx = {
@@ -110,7 +139,8 @@ async function getAugmentingRequestInformation(l1Requests: Request[]) {
return (
l1RequestEvents.find((event) => {
if (
- l1Request.identifier.toLowerCase() == event?.args?.identifier.toLowerCase() &&
+ l1Request.identifier.toLowerCase() ==
+ event?.args?.identifier.toLowerCase() &&
l1Request.time == event?.args?.time
) {
return true;
@@ -119,7 +149,9 @@ async function getAugmentingRequestInformation(l1Requests: Request[]) {
);
});
- const requestTransactions = await getRequestTxFromL1RequestInformation(l1Requests);
+ const requestTransactions = await getRequestTxFromL1RequestInformation(
+ l1Requests
+ );
return l1RequestTxHashes.map((l1RequestTxHash, index) => {
return {
@@ -133,20 +165,27 @@ async function getAugmentingRequestInformation(l1Requests: Request[]) {
});
}
-export default async function handler(request: NextApiRequest, response: NextApiResponse) {
+export default async function handler(
+ request: NextApiRequest,
+ response: NextApiResponse
+) {
response.setHeader("Cache-Control", "max-age=0, s-maxage=2592000"); // Cache for 30 days and re-build cache if re-deployed.
try {
const body = request.body;
["l1Requests"].forEach((requiredKey) => {
- if (!Object.keys(body).includes(requiredKey)) throw "Missing key in req body! required: l1Requests";
+ if (!Object.keys(body).includes(requiredKey))
+ throw "Missing key in req body! required: l1Requests";
});
- const readableTxData = await getAugmentingRequestInformation(body.l1Requests);
+ const readableTxData = await getAugmentingRequestInformation(
+ body.l1Requests
+ );
response.status(200).send(readableTxData);
} catch (e) {
console.error(e);
- response
- .status(500)
- .send({ message: "Error in fetching augmented information", error: e instanceof Error ? e.message : e });
+ response.status(500).send({
+ message: "Error in fetching augmented information",
+ error: e instanceof Error ? e.message : e,
+ });
}
}
diff --git a/pages/api/decode-admin.ts b/pages/api/decode-admin.ts
index 1313c345..f5dea991 100644
--- a/pages/api/decode-admin.ts
+++ b/pages/api/decode-admin.ts
@@ -19,11 +19,14 @@ export class TransactionDataDecoder {
public readonly abiDecoder: AbiDecoder;
private constructor() {
this.abiDecoder = abiDecoder;
- getContractNames().forEach((name: any) => this.abiDecoder.addABI(getAbi(name)));
+ getContractNames().forEach((name: any) =>
+ this.abiDecoder.addABI(getAbi(name))
+ );
}
public static getInstance(): TransactionDataDecoder {
- if (!TransactionDataDecoder.instance) TransactionDataDecoder.instance = new TransactionDataDecoder();
+ if (!TransactionDataDecoder.instance)
+ TransactionDataDecoder.instance = new TransactionDataDecoder();
return TransactionDataDecoder.instance;
}
@@ -47,7 +50,11 @@ export function decodeTransaction(transaction: Transaction): string {
returnValue += "\nValue (in Wei): " + transaction.value;
// No data -> simple ETH send.
- if (!transaction.data || transaction.data.length === 0 || transaction.data === "0x")
+ if (
+ !transaction.data ||
+ transaction.data.length === 0 ||
+ transaction.data === "0x"
+ )
returnValue += "\nTransaction is a simple ETH send (no data).";
else {
// Loading the abi decoder is expensive, so do it only if called and cache it for repeated use.
@@ -57,7 +64,8 @@ export function decodeTransaction(transaction: Transaction): string {
const decodedTxn = decoder.decodeTransaction(transaction.data);
if (!decodedTxn) {
// Cannot decode txn, just give the user the raw data.
- returnValue += "\nCannot decode transaction (does not match any UMA Protocol Signature).";
+ returnValue +=
+ "\nCannot decode transaction (does not match any UMA Protocol Signature).";
returnValue += "\nRaw transaction data: " + transaction.data;
} else {
// Decode was successful -- pretty print the results.
@@ -72,7 +80,10 @@ function _decodeData(data: any) {
return TransactionDataDecoder.getInstance().decodeTransaction(data);
}
-const _generateTransactionDataRecursive = function (txnObj: any, readableTxData = "") {
+const _generateTransactionDataRecursive = function (
+ txnObj: any,
+ readableTxData = ""
+) {
// If transaction is a proposal then recursively print out its transactions
if (txnObj.name === "propose" && txnObj.params.transactions.length > 0) {
readableTxData += `Transaction is a proposal containing ${txnObj.params.transactions.length} transactions:\n`;
@@ -90,7 +101,10 @@ const _generateTransactionDataRecursive = function (txnObj: any, readableTxData
);
});
// cross-chain governance
- } else if (txnObj.name === "relayGovernance" && txnObj?.params?.calls?.length > 0) {
+ } else if (
+ txnObj.name === "relayGovernance" &&
+ txnObj?.params?.calls?.length > 0
+ ) {
readableTxData += `Transaction is a cross-chain governance action proposal containing ${txnObj?.params?.calls?.length} transactions:\n`;
txnObj.params.calls.forEach((_txn: any) => {
const decodedTxnData = _decodeData(_txn.data);
@@ -119,7 +133,11 @@ const _generateTransactionDataRecursive = function (txnObj: any, readableTxData
});
} else {
// Pretty print:
- readableTxData += `\nNested transactions: \n${JSON.stringify(txnObj, null, 4)}`;
+ readableTxData += `\nNested transactions: \n${JSON.stringify(
+ txnObj,
+ null,
+ 4
+ )}`;
}
return readableTxData;
};
@@ -140,8 +158,11 @@ async function generateReadableAdminTransactionData(identifiers: string[]) {
const transactions = identifiers
.map(
(identifier) =>
- events.find((event) => event?.args?.id.toString() === identifier.substring(identifier.indexOf(" ") + 1))?.args
- ?.transactions || null
+ events.find(
+ (event) =>
+ event?.args?.id.toString() ===
+ identifier.substring(identifier.indexOf(" ") + 1)
+ )?.args?.transactions || null
)
.flat();
@@ -150,23 +171,34 @@ async function generateReadableAdminTransactionData(identifiers: string[]) {
data: transaction.data,
to: transaction.to,
value: transaction.value,
- decodedData: _generateTransactionDataRecursive(_decodeData(transaction.data)),
+ decodedData: _generateTransactionDataRecursive(
+ _decodeData(transaction.data)
+ ),
};
});
}
-export default async function handler(request: NextApiRequest, response: NextApiResponse) {
+export default async function handler(
+ request: NextApiRequest,
+ response: NextApiResponse
+) {
response.setHeader("Cache-Control", "max-age=0, s-maxage=2592000"); // Cache for 30 days and re-build cache if re-deployed.
try {
const body = request.body;
["identifiers"].forEach((requiredKey) => {
- if (!Object.keys(body).includes(requiredKey)) throw "Missing key in req body! required: identifiers";
+ if (!Object.keys(body).includes(requiredKey))
+ throw "Missing key in req body! required: identifiers";
});
- const readableTxData = await generateReadableAdminTransactionData(body.identifiers);
+ const readableTxData = await generateReadableAdminTransactionData(
+ body.identifiers
+ );
response.status(200).send(readableTxData);
} catch (e) {
console.error(e);
- response.status(500).send({ message: "Error in decoding admin call", error: e instanceof Error ? e.message : e });
+ response.status(500).send({
+ message: "Error in decoding admin call",
+ error: e instanceof Error ? e.message : e,
+ });
}
}
diff --git a/scripts/approvedIdentifiersTableParser.ts b/scripts/approvedIdentifiersTableParser.ts
index 2caee4cd..a734e401 100644
--- a/scripts/approvedIdentifiersTableParser.ts
+++ b/scripts/approvedIdentifiersTableParser.ts
@@ -9,8 +9,14 @@ async function main() {
// first download the table of approved identifiers from our docs
const url =
"https://raw.githubusercontent.com/UMAprotocol/docs/master/docs/uma-tokenholders/approved-price-identifiers.md";
- const markdownPath = path.join(__dirname, "../data/approvedIdentifiersTable.md");
- const jsonPath = path.join(__dirname, "../data/approvedIdentifiersTable.json");
+ const markdownPath = path.join(
+ __dirname,
+ "../data/approvedIdentifiersTable.md"
+ );
+ const jsonPath = path.join(
+ __dirname,
+ "../data/approvedIdentifiersTable.json"
+ );
await downloadFile(url, markdownPath);
@@ -60,8 +66,14 @@ function parseLine(line: string): IdentifierDetailsT {
}
function parseMarkdownUmipLink(umipLink: string): UmipLinkT {
- const number = umipLink.substring(umipLink.indexOf("[") + 1, umipLink.indexOf("]"));
- const url = umipLink.substring(umipLink.indexOf("(") + 1, umipLink.indexOf(")"));
+ const number = umipLink.substring(
+ umipLink.indexOf("[") + 1,
+ umipLink.indexOf("]")
+ );
+ const url = umipLink.substring(
+ umipLink.indexOf("(") + 1,
+ umipLink.indexOf(")")
+ );
return { number, url };
}
diff --git a/stories/BaseComponents/errors/ErrorBanner.stories.tsx b/stories/BaseComponents/errors/ErrorBanner.stories.tsx
index a35aeb8d..e418a6e6 100644
--- a/stories/BaseComponents/errors/ErrorBanner.stories.tsx
+++ b/stories/BaseComponents/errors/ErrorBanner.stories.tsx
@@ -19,7 +19,8 @@ export default {
const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
const errorOrigin = "storybook";
const { errorMessages } = args;
- const { addErrorMessage, removeErrorMessage, clearErrorMessages } = useErrorContext(errorOrigin);
+ const { addErrorMessage, removeErrorMessage, clearErrorMessages } =
+ useErrorContext(errorOrigin);
const [errorText, setErrorText] = useState("Test error message");
useEffect(() => {
@@ -33,9 +34,21 @@ const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
-
>
@@ -44,7 +57,9 @@ const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
export const OneErrorMessage = Template.bind({});
OneErrorMessage.args = {
- errorMessages: ["You seem to be offline. Please check your internet connection and try again."],
+ errorMessages: [
+ "You seem to be offline. Please check your internet connection and try again.",
+ ],
};
export const MultipleErrorMessages = Template.bind({});
@@ -68,7 +83,8 @@ export const CustomMarkup = Template.bind({});
CustomMarkup.args = {
errorMessages: [
<>
- You seem to be offline. Please check your internet connection and try again.
+ You seem to be offline.{" "}
+ Please check your internet connection and try again.
>,
],
};
diff --git a/stories/BaseComponents/errors/PanelErrorBanner.stories.tsx b/stories/BaseComponents/errors/PanelErrorBanner.stories.tsx
index 6c6f84da..c00fa0e4 100644
--- a/stories/BaseComponents/errors/PanelErrorBanner.stories.tsx
+++ b/stories/BaseComponents/errors/PanelErrorBanner.stories.tsx
@@ -1,6 +1,6 @@
import { Meta, Story } from "@storybook/react";
import { Button, PanelErrorBanner, TextInput } from "components";
-import { desktopPanelWidth } from "constants/containers";
+import { desktopPanelWidth } from "constant";
import { ErrorProvider } from "contexts";
import { useErrorContext } from "hooks";
import { ReactNode, useEffect, useState } from "react";
@@ -22,7 +22,8 @@ export default {
const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
const errorOrigin = "storybook";
const { errorMessages } = args;
- const { addErrorMessage, removeErrorMessage, clearErrorMessages } = useErrorContext(errorOrigin);
+ const { addErrorMessage, removeErrorMessage, clearErrorMessages } =
+ useErrorContext(errorOrigin);
const [errorText, setErrorText] = useState("Test error message");
useEffect(() => {
@@ -36,9 +37,21 @@ const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
- addErrorMessage(errorText)} label="Add error from text" variant="primary" />
- removeErrorMessage(errorText)} label="Remove error from text" variant="primary" />
-
+ addErrorMessage(errorText)}
+ label="Add error from text"
+ variant="primary"
+ />
+ removeErrorMessage(errorText)}
+ label="Remove error from text"
+ variant="primary"
+ />
+
>
@@ -47,7 +60,9 @@ const Template: Story<{ errorMessages: ReactNode[] }> = (args) => {
export const OneErrorMessage = Template.bind({});
OneErrorMessage.args = {
- errorMessages: ["You seem to be offline. Please check your internet connection and try again."],
+ errorMessages: [
+ "You seem to be offline. Please check your internet connection and try again.",
+ ],
};
export const MultipleErrorMessages = Template.bind({});
@@ -71,7 +86,8 @@ export const CustomMarkup = Template.bind({});
CustomMarkup.args = {
errorMessages: [
<>
- You seem to be offline. Please check your internet connection and try again.
+ You seem to be offline.{" "}
+ Please check your internet connection and try again.
>,
],
};
diff --git a/stories/BaseComponents/info/CooldownTimer.stories.tsx b/stories/BaseComponents/info/CooldownTimer.stories.tsx
index 58de8f91..8fdd055a 100644
--- a/stories/BaseComponents/info/CooldownTimer.stories.tsx
+++ b/stories/BaseComponents/info/CooldownTimer.stories.tsx
@@ -1,6 +1,6 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { CooldownTimer } from "components";
-import { red500 } from "constants/colors";
+import { red500 } from "constant";
import add from "date-fns/add";
import { BigNumber } from "ethers";
@@ -25,7 +25,9 @@ export default {
],
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const InCooldown = Template.bind({});
InCooldown.args = {
diff --git a/stories/BaseComponents/info/DonutChart.stories.tsx b/stories/BaseComponents/info/DonutChart.stories.tsx
index 8ef43866..a258be5a 100644
--- a/stories/BaseComponents/info/DonutChart.stories.tsx
+++ b/stories/BaseComponents/info/DonutChart.stories.tsx
@@ -6,10 +6,15 @@ export default {
component: DonutChart,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
const length = 3;
-const data = Array.from({ length }).map((_, i) => ({ label: `Segment ${i + 1}`, value: 1 / length }));
+const data = Array.from({ length }).map((_, i) => ({
+ label: `Segment ${i + 1}`,
+ value: 1 / length,
+}));
export const Default = Template.bind({});
Default.args = {
diff --git a/stories/BaseComponents/info/Notifications.stories.tsx b/stories/BaseComponents/info/Notifications.stories.tsx
index 0eda3829..f0c51b5f 100644
--- a/stories/BaseComponents/info/Notifications.stories.tsx
+++ b/stories/BaseComponents/info/Notifications.stories.tsx
@@ -1,6 +1,9 @@
import { Meta, Story } from "@storybook/react";
import { Notifications } from "components";
-import { defaultNotificationsContextState, NotificationsContext } from "contexts";
+import {
+ defaultNotificationsContextState,
+ NotificationsContext,
+} from "contexts";
import { NotificationsById } from "contexts/NotificationsContext";
import uniqueId from "lodash/uniqueId";
@@ -32,7 +35,8 @@ OneNotification.args = {
notifications: {
[mockId1]: {
message: "Test notification. Committing votes or something",
- transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
+ transactionHash:
+ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
type: "pending",
id: mockId1,
},
@@ -44,19 +48,22 @@ MultipleNotifications.args = {
notifications: {
[mockId1]: {
message: "Test notification. Committing votes or something",
- transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
+ transactionHash:
+ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
type: "pending",
id: mockId1,
},
[mockId2]: {
message: "Testing testing one two three",
- transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdea",
+ transactionHash:
+ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdea",
type: "error",
id: mockId2,
},
[mockId3]: {
message: "Another one. DJ Khaled!",
- transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdee",
+ transactionHash:
+ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdee",
type: "success",
id: mockId3,
},
diff --git a/stories/BaseComponents/info/Tooltip.stories.tsx b/stories/BaseComponents/info/Tooltip.stories.tsx
index bcba3faa..e77ab41c 100644
--- a/stories/BaseComponents/info/Tooltip.stories.tsx
+++ b/stories/BaseComponents/info/Tooltip.stories.tsx
@@ -8,7 +8,10 @@ export default {
const Template: ComponentStory = (args) => (
-
+
{args.children ?? Hover me
}
diff --git a/stories/BaseComponents/inputs/AmountInput.stories.tsx b/stories/BaseComponents/inputs/AmountInput.stories.tsx
index 9726899e..bd84f198 100644
--- a/stories/BaseComponents/inputs/AmountInput.stories.tsx
+++ b/stories/BaseComponents/inputs/AmountInput.stories.tsx
@@ -11,7 +11,11 @@ const Template: ComponentStory = (args) => {
const [_args, updateArgs] = useArgs();
return (
- updateArgs({ value })} onMax={() => updateArgs({ value: 10000 })} />
+ updateArgs({ value })}
+ onMax={() => updateArgs({ value: 10000 })}
+ />
);
};
diff --git a/stories/BaseComponents/inputs/Checkbox.stories.tsx b/stories/BaseComponents/inputs/Checkbox.stories.tsx
index 56833410..dd43609e 100644
--- a/stories/BaseComponents/inputs/Checkbox.stories.tsx
+++ b/stories/BaseComponents/inputs/Checkbox.stories.tsx
@@ -17,7 +17,12 @@ export default {
const Template: ComponentStory = (args) => {
const [_args, updateArgs] = useArgs();
- return updateArgs({ checked: e.target.checked })} />;
+ return (
+ updateArgs({ checked: e.target.checked })}
+ />
+ );
};
export const Unchecked = Template.bind({});
diff --git a/stories/BaseComponents/inputs/Dropdown.stories.tsx b/stories/BaseComponents/inputs/Dropdown.stories.tsx
index 7ae51f23..d6a2d294 100644
--- a/stories/BaseComponents/inputs/Dropdown.stories.tsx
+++ b/stories/BaseComponents/inputs/Dropdown.stories.tsx
@@ -1,7 +1,7 @@
import { useArgs } from "@storybook/client-api";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Dropdown } from "components";
-import { blackOpacity25 } from "constants/colors";
+import { blackOpacity25 } from "constant";
const defaultMockItems = [
{ label: "Yes", value: "p0", secondaryLabel: "p0" },
diff --git a/stories/BaseComponents/inputs/Toggle.stories.tsx b/stories/BaseComponents/inputs/Toggle.stories.tsx
index 0b998a80..ccd37f53 100644
--- a/stories/BaseComponents/inputs/Toggle.stories.tsx
+++ b/stories/BaseComponents/inputs/Toggle.stories.tsx
@@ -17,7 +17,9 @@ export default {
const Template: ComponentStory = (args) => {
const [_args, updateArgs] = useArgs();
- return updateArgs({ clicked: !args.clicked })} />;
+ return (
+ updateArgs({ clicked: !args.clicked })} />
+ );
};
export const NotClicked = Template.bind({});
diff --git a/stories/BaseComponents/loaders/LoadingSkeleton.stories.tsx b/stories/BaseComponents/loaders/LoadingSkeleton.stories.tsx
index 7c906fd2..da00535e 100644
--- a/stories/BaseComponents/loaders/LoadingSkeleton.stories.tsx
+++ b/stories/BaseComponents/loaders/LoadingSkeleton.stories.tsx
@@ -1,6 +1,6 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { LoadingSkeleton } from "components";
-import { red500 } from "constants/colors";
+import { red500 } from "constant";
export default {
title: "Base components/Loaders/Loading Skeleton",
@@ -14,7 +14,9 @@ export default {
],
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const Default = Template.bind({});
@@ -44,7 +46,15 @@ WhiteVariant.args = {
};
WhiteVariant.decorators = [
(Story) => (
-
+
),
diff --git a/stories/BaseComponents/loaders/LoadingSpinner.stories.tsx b/stories/BaseComponents/loaders/LoadingSpinner.stories.tsx
index a599d653..de7a331c 100644
--- a/stories/BaseComponents/loaders/LoadingSpinner.stories.tsx
+++ b/stories/BaseComponents/loaders/LoadingSpinner.stories.tsx
@@ -6,7 +6,9 @@ export default {
component: LoadingSpinner,
} as ComponentMeta
;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const Default = Template.bind({});
diff --git a/stories/BaseComponents/navigation/Header.stories.tsx b/stories/BaseComponents/navigation/Header.stories.tsx
index 1ff0351c..5e7b79c9 100644
--- a/stories/BaseComponents/navigation/Header.stories.tsx
+++ b/stories/BaseComponents/navigation/Header.stories.tsx
@@ -1,7 +1,11 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Meta, Story } from "@storybook/react";
import { Header } from "components";
-import { defaultDelegationContextState, DelegationContext, DelegationContextState } from "contexts";
+import {
+ defaultDelegationContextState,
+ DelegationContext,
+ DelegationContextState,
+} from "contexts";
import { DelegationStatusT } from "types";
interface StoryProps {
diff --git a/stories/BaseComponents/navigation/Pagination.stories.tsx b/stories/BaseComponents/navigation/Pagination.stories.tsx
index d7af7c1f..a6b07a79 100644
--- a/stories/BaseComponents/navigation/Pagination.stories.tsx
+++ b/stories/BaseComponents/navigation/Pagination.stories.tsx
@@ -6,10 +6,14 @@ import { useArgs } from "@storybook/client-api";
import { Meta, Story } from "@storybook/react";
import { Pagination } from "components";
import { Props as PaginationProps } from "components/Pagination/Pagination";
-import { grey100 } from "constants/colors";
-import { defaultPaginationContextState, PaginationContext, PaginationContextState } from "contexts";
+import { grey100 } from "constant";
+import {
+ defaultPaginationContextState,
+ PaginationContext,
+ PaginationContextState,
+} from "contexts";
import { defaultPageStates } from "contexts/PaginationContext";
-import { PageStatesT, PaginateForT } from "types/global";
+import { PageStatesT, PaginateForT } from "types";
interface StoryProps extends PaginationProps {
pageStates: PageStatesT;
@@ -27,27 +31,36 @@ export default {
const pageStates = args.pageStates ?? defaultPageStates;
function goToPage(paginateFor: PaginateForT, number: number) {
- updateArgs({ ...pageStates, [paginateFor]: (pageStates[paginateFor].number = number) });
+ updateArgs({
+ ...pageStates,
+ [paginateFor]: (pageStates[paginateFor].number = number),
+ });
}
function nextPage(paginateFor: PaginateForT) {
updateArgs({
...pageStates,
- [paginateFor]: (pageStates[paginateFor].number = pageStates[paginateFor].number + 1),
+ [paginateFor]: (pageStates[paginateFor].number =
+ pageStates[paginateFor].number + 1),
});
}
function previousPage(paginateFor: PaginateForT) {
updateArgs({
...pageStates,
- [paginateFor]: (pageStates[paginateFor].number = pageStates[paginateFor].number - 1),
+ [paginateFor]: (pageStates[paginateFor].number =
+ pageStates[paginateFor].number - 1),
});
}
- function setResultsPerPage(paginateFor: PaginateForT, resultsPerPage: number) {
+ function setResultsPerPage(
+ paginateFor: PaginateForT,
+ resultsPerPage: number
+ ) {
updateArgs({
...pageStates,
- [paginateFor]: (pageStates[paginateFor].resultsPerPage = resultsPerPage),
+ [paginateFor]: (pageStates[paginateFor].resultsPerPage =
+ resultsPerPage),
});
}
@@ -67,7 +80,14 @@ export default {
);
},
(Story) => (
-
+
),
diff --git a/stories/BaseComponents/navigation/Panel.stories.tsx b/stories/BaseComponents/navigation/Panel.stories.tsx
index 9599d20a..8bfde14f 100644
--- a/stories/BaseComponents/navigation/Panel.stories.tsx
+++ b/stories/BaseComponents/navigation/Panel.stories.tsx
@@ -22,7 +22,11 @@ import {
} from "contexts";
import { BigNumber } from "ethers";
import { bigNumberFromFloatString, zeroAddress } from "helpers";
-import { mockAddress1, mockAddress2, mockDelegateRequestTransaction } from "stories/mocks/delegation";
+import {
+ mockAddress1,
+ mockAddress2,
+ mockDelegateRequestTransaction,
+} from "stories/mocks/delegation";
import { mockWalletIcon } from "stories/mocks/mockWalletIcon";
import { makeMockVotesWithHistory, voteCommitted } from "stories/mocks/votes";
import { DelegationEventT, DelegationStatusT, VoteT } from "types";
@@ -101,8 +105,10 @@ const userDecorator: DecoratorFn = (Story, { args }) => {
const mockUserContextState: UserContextState = {
...defaultUserContextState,
apr: args.apr ?? 0,
- cumulativeCalculatedSlash: args.cumulativeCalculatedSlash ?? BigNumber.from(0),
- cumulativeCalculatedSlashPercentage: args.cumulativeCalculatedSlashPercentage ?? BigNumber.from(0),
+ cumulativeCalculatedSlash:
+ args.cumulativeCalculatedSlash ?? BigNumber.from(0),
+ cumulativeCalculatedSlashPercentage:
+ args.cumulativeCalculatedSlashPercentage ?? BigNumber.from(0),
userDataFetching: args.userDataFetching ?? false,
address: args.address ?? mockAddress1,
walletIcon: args.walletIcon ?? mockWalletIcon,
@@ -133,8 +139,10 @@ const delegationDecorator: DecoratorFn = (Story, { args }) => {
const mockDelegationContextState: DelegationContextState = {
...defaultDelegationContextState,
getDelegationStatus: () => args.delegationStatus ?? "no-delegation",
- getPendingSentRequestsToBeDelegate: () => args.pendingSentRequestsToBeDelegate ?? [],
- getPendingReceivedRequestsToBeDelegate: () => args.pendingReceivedRequestsToBeDelegate ?? [],
+ getPendingSentRequestsToBeDelegate: () =>
+ args.pendingSentRequestsToBeDelegate ?? [],
+ getPendingReceivedRequestsToBeDelegate: () =>
+ args.pendingReceivedRequestsToBeDelegate ?? [],
getDelegateAddress: () => args.delegateAddress ?? zeroAddress,
getDelegatorAddress: () => args.delegatorAddress ?? zeroAddress,
};
@@ -283,7 +291,8 @@ VotePanelWithLongTitle.args = {
...VotePanelWithoutResults.args,
panelContent: {
...voteCommitted,
- title: "Will Coinbase support Polygon USDC deposits & withdrawals by June 30, 2022?",
+ title:
+ "Will Coinbase support Polygon USDC deposits & withdrawals by June 30, 2022?",
},
};
@@ -362,7 +371,8 @@ DelegationPanelWhenStatusIsDelegatePending.args = {
...delegationPanelCommonArgs,
delegationStatus: "delegate-pending",
};
-DelegationPanelWhenStatusIsDelegatePending.decorators = delegationPanelDecorators;
+DelegationPanelWhenStatusIsDelegatePending.decorators =
+ delegationPanelDecorators;
// this should render nothing in the panel because we don't allow a delegator to add another delegate
export const DelegationPanelWhenStatusIsDelegator = Template.bind({});
@@ -391,4 +401,5 @@ DelegationPanelWhenStatusIsDelegatorPending.args = {
},
],
};
-DelegationPanelWhenStatusIsDelegatorPending.decorators = delegationPanelDecorators;
+DelegationPanelWhenStatusIsDelegatorPending.decorators =
+ delegationPanelDecorators;
diff --git a/stories/BaseComponents/navigation/VoteHistoryTable.stories.tsx b/stories/BaseComponents/navigation/VoteHistoryTable.stories.tsx
index a79ee48e..cd71db77 100644
--- a/stories/BaseComponents/navigation/VoteHistoryTable.stories.tsx
+++ b/stories/BaseComponents/navigation/VoteHistoryTable.stories.tsx
@@ -14,7 +14,9 @@ export default {
],
} as ComponentMeta
;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const Default = Template.bind({});
Default.args = {
diff --git a/stories/Pages/PastVotesPage.stories.tsx b/stories/Pages/PastVotesPage.stories.tsx
index 6d5eca15..be92c4af 100644
--- a/stories/Pages/PastVotesPage.stories.tsx
+++ b/stories/Pages/PastVotesPage.stories.tsx
@@ -6,7 +6,8 @@ import { VoteT } from "types";
const mockPastVotes = Array.from({ length: 200 }).map((_, i) => ({
time: 1666025124,
- identifier: "0x5945535f4f525f4e4f5f51554552590000000000000000000000000000000000",
+ identifier:
+ "0x5945535f4f525f4e4f5f51554552590000000000000000000000000000000000",
ancillaryData:
"0x713a224861642074686520666f6c6c6f77696e6720696e7375726564206576656e74206f63637572726564206173206f6620726571756573742074696d657374616d703a20546f6d20617465204a657272793f222c6f6f5265717565737465723a30343338653733386362376231656239386238636239663236643661313164353935303662396464",
voteNumber: BigNumber.from("0x86"),
@@ -21,7 +22,8 @@ const mockPastVotes = Array.from({ length: 200 }).map((_, i) => ({
Math.random().toString(),
isCommitted: false,
isRevealed: false,
- transactionHash: "0x2a37d6072ef32814755e67e40b118d5c3f8d389fb1d9e80f0a75037aa042ea39",
+ transactionHash:
+ "0x2a37d6072ef32814755e67e40b118d5c3f8d389fb1d9e80f0a75037aa042ea39",
voteHistory: {
uniqueKey:
"YES_OR_NO_QUERY-1666025124-0x713a224861642074686520666f6c6c6f77696e6720696e7375726564206576656e74206f63637572726564206173206f6620726571756573742074696d657374616d703a20546f6d20617465204a657272793f222c6f6f5265717565737465723a30343338653733386362376231656239386238636239663236643661313164353935303662396464" +
diff --git a/stories/Pages/VotePage/InfoBar.stories.tsx b/stories/Pages/VotePage/InfoBar.stories.tsx
index 1d6aa52c..445dd943 100644
--- a/stories/Pages/VotePage/InfoBar.stories.tsx
+++ b/stories/Pages/VotePage/InfoBar.stories.tsx
@@ -8,7 +8,9 @@ export default {
component: InfoBar,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const WithButton = Template.bind({});
WithButton.args = {
diff --git a/stories/Pages/VotePage/VoteTableRow.stories.tsx b/stories/Pages/VotePage/VoteTableRow.stories.tsx
index 2ab0bc95..315b8db0 100644
--- a/stories/Pages/VotePage/VoteTableRow.stories.tsx
+++ b/stories/Pages/VotePage/VoteTableRow.stories.tsx
@@ -21,7 +21,9 @@ export default {
],
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
const mockMoreDetailsAction = () => alert("More details clicked");
diff --git a/stories/Pages/VotePage/VoteTimeline.stories.tsx b/stories/Pages/VotePage/VoteTimeline.stories.tsx
index 20482171..9855649e 100644
--- a/stories/Pages/VotePage/VoteTimeline.stories.tsx
+++ b/stories/Pages/VotePage/VoteTimeline.stories.tsx
@@ -1,6 +1,11 @@
import { Meta, Story } from "@storybook/react";
import { VoteTimeline } from "components";
-import { defaultVotesContextState, defaultVoteTimingContextState, VotesContext, VoteTimingContext } from "contexts";
+import {
+ defaultVotesContextState,
+ defaultVoteTimingContextState,
+ VotesContext,
+ VoteTimingContext,
+} from "contexts";
interface StoryProps {
phase: "commit" | "reveal";
diff --git a/stories/Pages/VotePage/Votes.stories.tsx b/stories/Pages/VotePage/Votes.stories.tsx
index 2da32321..5e5dfe74 100644
--- a/stories/Pages/VotePage/Votes.stories.tsx
+++ b/stories/Pages/VotePage/Votes.stories.tsx
@@ -1,7 +1,12 @@
import { Meta, Story } from "@storybook/react";
import { Votes } from "components";
-import { desktopMaxWidth } from "constants/containers";
-import { defaultVotesContextState, defaultVoteTimingContextState, VotesContext, VoteTimingContext } from "contexts";
+import { desktopMaxWidth } from "constant";
+import {
+ defaultVotesContextState,
+ defaultVoteTimingContextState,
+ VotesContext,
+ VoteTimingContext,
+} from "contexts";
import {
voteCommitted,
voteCommittedButNotRevealed,
@@ -60,20 +65,34 @@ export const ActiveCommit = Template.bind({});
ActiveCommit.args = {
activityStatus: "active",
phase: "commit",
- activeVotes: [voteWithoutUserVote, voteCommitted, voteWithoutUserVote, voteCommitted],
+ activeVotes: [
+ voteWithoutUserVote,
+ voteCommitted,
+ voteWithoutUserVote,
+ voteCommitted,
+ ],
};
export const ActiveReveal = Template.bind({});
ActiveReveal.args = {
activityStatus: "active",
phase: "reveal",
- activeVotes: [voteCommittedButNotRevealed, voteRevealed, voteCommittedButNotRevealed, voteRevealed],
+ activeVotes: [
+ voteCommittedButNotRevealed,
+ voteRevealed,
+ voteCommittedButNotRevealed,
+ voteRevealed,
+ ],
};
export const Upcoming = Template.bind({});
Upcoming.args = {
activityStatus: "upcoming",
- upcomingVotes: [voteWithoutUserVote, voteWithoutUserVote, voteWithoutUserVote],
+ upcomingVotes: [
+ voteWithoutUserVote,
+ voteWithoutUserVote,
+ voteWithoutUserVote,
+ ],
};
export const Past = Template.bind({});
diff --git a/stories/Pages/VotePage/VotesTable.stories.tsx b/stories/Pages/VotePage/VotesTable.stories.tsx
index 3aa50b77..1db7b95d 100644
--- a/stories/Pages/VotePage/VotesTable.stories.tsx
+++ b/stories/Pages/VotePage/VotesTable.stories.tsx
@@ -38,8 +38,10 @@ const Template: Story = (args) => {
export const ActiveCommit = Template.bind({});
ActiveCommit.args = {
- // @ts-expect-error - Storybook makes all args optional, but we know they're not.
- headings: ,
+ headings: (
+ // @ts-expect-error - Storybook makes all args optional, but we know they're not.
+
+ ),
rows: [
// @ts-expect-error - Storybook makes all args optional, but we know they're not.
,
@@ -54,8 +56,10 @@ ActiveCommit.args = {
export const ActiveReveal = Template.bind({});
ActiveReveal.args = {
- // @ts-expect-error - Storybook makes all args optional, but we know they're not.
- headings: ,
+ headings: (
+ // @ts-expect-error - Storybook makes all args optional, but we know they're not.
+
+ ),
rows: [
// @ts-expect-error - Storybook makes all args optional, but we know they're not.
,
@@ -72,8 +76,10 @@ ActiveReveal.args = {
export const Upcoming = Template.bind({});
Upcoming.args = {
- // @ts-expect-error - Storybook makes all args optional, but we know they're not.
- headings: ,
+ headings: (
+ // @ts-expect-error - Storybook makes all args optional, but we know they're not.
+
+ ),
rows: [
// @ts-expect-error - Storybook makes all args optional, but we know they're not.
,
diff --git a/stories/Pages/VotePage/VotesTableHeadings.stories.tsx b/stories/Pages/VotePage/VotesTableHeadings.stories.tsx
index cb66d241..18363a14 100644
--- a/stories/Pages/VotePage/VotesTableHeadings.stories.tsx
+++ b/stories/Pages/VotePage/VotesTableHeadings.stories.tsx
@@ -6,7 +6,9 @@ export default {
component: VotesTableHeadings,
} as ComponentMeta;
-const Template: ComponentStory = (args) => ;
+const Template: ComponentStory = (args) => (
+
+);
export const Active = Template.bind({});
Active.args = {
diff --git a/stories/Pages/WalletSettingsPage/Wallets.stories.tsx b/stories/Pages/WalletSettingsPage/Wallets.stories.tsx
index a4e6a207..a180f558 100644
--- a/stories/Pages/WalletSettingsPage/Wallets.stories.tsx
+++ b/stories/Pages/WalletSettingsPage/Wallets.stories.tsx
@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { Meta, Story } from "@storybook/react";
import { Wallets } from "components";
-import { grey100 } from "constants/colors";
+import { grey100 } from "constant";
import {
defaultDelegationContextState,
defaultUserContextState,
@@ -11,7 +11,12 @@ import {
UserContext,
UserContextState,
} from "contexts";
-import { mockAddress1, mockAddress2, mockAddress3, mockDelegateRequestTransaction } from "stories/mocks/delegation";
+import {
+ mockAddress1,
+ mockAddress2,
+ mockAddress3,
+ mockDelegateRequestTransaction,
+} from "stories/mocks/delegation";
import { mockWalletIcon } from "stories/mocks/mockWalletIcon";
import { DelegationEventT, DelegationStatusT } from "types";
@@ -32,7 +37,14 @@ export default {
component: Wallets,
decorators: [
(Story) => (
-
+
),
@@ -52,21 +64,32 @@ export default {
const mockDelegationContextState = {
...defaultDelegationContextState,
getDelegationStatus: () => args.delegationStatus ?? "no-delegation",
- getPendingReceivedRequestsToBeDelegate: () => args.pendingReceivedRequestsToBeDelegate ?? [],
- getHasPendingReceivedRequestsToBeDelegate: () => args.hasPendingReceivedRequestsToBeDelegate ?? false,
- getPendingSentRequestsToBeDelegate: () => args.pendingSentRequestsToBeDelegate ?? [],
- getHasPendingSentRequestsToBeDelegate: () => args.hasPendingSentRequestsToBeDelegate ?? false,
+ getPendingReceivedRequestsToBeDelegate: () =>
+ args.pendingReceivedRequestsToBeDelegate ?? [],
+ getHasPendingReceivedRequestsToBeDelegate: () =>
+ args.hasPendingReceivedRequestsToBeDelegate ?? false,
+ getPendingSentRequestsToBeDelegate: () =>
+ args.pendingSentRequestsToBeDelegate ?? [],
+ getHasPendingSentRequestsToBeDelegate: () =>
+ args.hasPendingSentRequestsToBeDelegate ?? false,
getDelegateAddress: () => args.delegateAddress,
getDelegatorAddress: () => args.delegatorAddress,
sendRequestToBeDelegate: (delegateAddress: string) =>
alert(`sent request to be delegate to ${delegateAddress}`),
- cancelSentRequestToBeDelegate: () => alert("cancelled sent request to be delegate"),
+ cancelSentRequestToBeDelegate: () =>
+ alert("cancelled sent request to be delegate"),
acceptReceivedRequestToBeDelegate: (delegatorAddress: string) =>
- alert(`accepted received request to be delegate from ${delegatorAddress}`),
+ alert(
+ `accepted received request to be delegate from ${delegatorAddress}`
+ ),
ignoreReceivedRequestToBeDelegate: (delegatorAddress: string) =>
- alert(`ignored received request to be delegate from ${delegatorAddress}`),
- terminateRelationshipWithDelegate: () => alert("terminated relationship with delegate"),
- terminateRelationshipWithDelegator: () => alert("terminated relationship with delegator"),
+ alert(
+ `ignored received request to be delegate from ${delegatorAddress}`
+ ),
+ terminateRelationshipWithDelegate: () =>
+ alert("terminated relationship with delegate"),
+ terminateRelationshipWithDelegator: () =>
+ alert("terminated relationship with delegator"),
};
return (
diff --git a/stories/mocks/delegation.ts b/stories/mocks/delegation.ts
index d9470fe7..f2246d72 100644
--- a/stories/mocks/delegation.ts
+++ b/stories/mocks/delegation.ts
@@ -1,4 +1,5 @@
export const mockAddress1 = "0x1234567890123456789012345678901234567890";
export const mockAddress2 = "0x0987654321098765432109876543210987654321";
export const mockAddress3 = "0xfedcba98761234567890fedcba98761234567890";
-export const mockDelegateRequestTransaction = "0xabcdef12345678901234567890abcdef12345678901234567890abcdefabcdef";
+export const mockDelegateRequestTransaction =
+ "0xabcdef12345678901234567890abcdef12345678901234567890abcdefabcdef";
diff --git a/stories/mocks/votes.ts b/stories/mocks/votes.ts
index 7f0e7059..a6324938 100644
--- a/stories/mocks/votes.ts
+++ b/stories/mocks/votes.ts
@@ -74,7 +74,10 @@ export const voteCommitted = {
export const voteCommittedButNotRevealed = { ...voteCommitted };
-export const voteRevealed = { ...voteCommittedButNotRevealed, isRevealed: true };
+export const voteRevealed = {
+ ...voteCommittedButNotRevealed,
+ isRevealed: true,
+};
export const voteWithCorrectVoteWithoutUserVote = {
...voteWithoutUserVote,
@@ -130,7 +133,10 @@ function makeMockVoteHistory(args?: VoteHistoryMockArgsT) {
correctness: args?.correctness ?? Math.random() > 0.5,
staking: args?.staking ?? Math.random() > 0.5,
slashAmount:
- args?.slashAmount ?? bigNumberFromFloatString(`${Math.random() > 0.5 ? "-" : ""}${Math.random() * 100}`),
+ args?.slashAmount ??
+ bigNumberFromFloatString(
+ `${Math.random() > 0.5 ? "-" : ""}${Math.random() * 100}`
+ ),
};
}
diff --git a/types/delegation.ts b/types/delegation.ts
new file mode 100644
index 00000000..514f028f
--- /dev/null
+++ b/types/delegation.ts
@@ -0,0 +1,13 @@
+export type DelegationStatusT =
+ | "no-wallet-connected"
+ | "no-delegation"
+ | "delegate"
+ | "delegator"
+ | "delegate-pending"
+ | "delegator-pending";
+
+export type DelegationEventT = {
+ delegate: string;
+ delegator: string;
+ transactionHash: string;
+};
diff --git a/types/index.ts b/types/index.ts
index 09370234..f16c879c 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -1 +1,7 @@
-export * from "./global";
+export * from "./delegation";
+export * from "./notifications";
+export * from "./queries";
+export * from "./staking";
+export * from "./ui";
+export * from "./user";
+export * from "./voting";
diff --git a/types/notifications.ts b/types/notifications.ts
new file mode 100644
index 00000000..47ce47c2
--- /dev/null
+++ b/types/notifications.ts
@@ -0,0 +1,19 @@
+import { uniqueId } from "lodash";
+import { ReactNode } from "react";
+
+export type UniqueIdT = ReturnType;
+
+export type NotificationT = {
+ message: ReactNode;
+ id: UniqueIdT;
+ transactionHash?: string;
+ type: "success" | "error" | "pending";
+};
+
+export type PendingNotificationT = NotificationT;
+
+export type SettledEventT = {
+ message: ReactNode;
+ id: UniqueIdT;
+ pendingId: UniqueIdT;
+};
diff --git a/types/queries.ts b/types/queries.ts
new file mode 100644
index 00000000..13d75540
--- /dev/null
+++ b/types/queries.ts
@@ -0,0 +1,31 @@
+export type PastVotesQuery = {
+ priceRequests: {
+ id: string;
+ identifier: {
+ id: string;
+ };
+ time: string;
+ price: string;
+ ancillaryData: string;
+ requestIndex: string;
+ }[];
+};
+
+export type UserDataQuery = {
+ users: {
+ annualPercentageReturn: string;
+ countReveals: string;
+ countNoVotes: string;
+ countWrongVotes: string;
+ countCorrectVotes: string;
+ cumulativeCalculatedSlash: string;
+ cumulativeCalculatedSlashPercentage: string;
+ votesSlashed: {
+ request: { id: string };
+ voted: boolean;
+ correctness: boolean;
+ staking: boolean;
+ slashAmount: string;
+ }[];
+ }[];
+};
diff --git a/types/staking.ts b/types/staking.ts
new file mode 100644
index 00000000..dda09aae
--- /dev/null
+++ b/types/staking.ts
@@ -0,0 +1,9 @@
+import { BigNumber } from "ethers";
+
+export type StakerDetailsT = {
+ stakedBalance: BigNumber;
+ pendingUnstake: BigNumber;
+ canUnstakeTime: Date | undefined;
+ unstakeRequestTime: Date | undefined;
+ delegate: string;
+};
diff --git a/types/ui.ts b/types/ui.ts
new file mode 100644
index 00000000..a720b231
--- /dev/null
+++ b/types/ui.ts
@@ -0,0 +1,51 @@
+import { VoteT } from "types";
+
+export type InputDataT = {
+ value: string | number;
+ label: string;
+};
+
+export type LinkT = {
+ href: string;
+ label: string;
+};
+
+export type DropdownItemT = InputDataT & {
+ secondaryLabel?: string;
+};
+
+export type PanelTypeT =
+ | "menu"
+ | "claim"
+ | "vote"
+ | "stake"
+ | "history"
+ | "remind"
+ | "delegation"
+ | null;
+
+export type VotePanelContentT = VoteT;
+
+export type PanelContentT = VotePanelContentT | null;
+
+export type PaginateForT =
+ | "activeVotesPage"
+ | "upcomingVotesPage"
+ | "pastVotesPage"
+ | "voteHistoryPage";
+
+export type PageStateT = {
+ pageNumber: number;
+ resultsPerPage: number;
+};
+
+export type PageStatesT = Record;
+
+export type ErrorOriginT =
+ | "default"
+ | "vote"
+ | "stake"
+ | "unstake"
+ | "claim"
+ | "delegation"
+ | "storybook";
diff --git a/types/user.ts b/types/user.ts
new file mode 100644
index 00000000..d97ffa51
--- /dev/null
+++ b/types/user.ts
@@ -0,0 +1,20 @@
+import { BigNumber } from "ethers";
+import { DecryptedVoteT, EncryptedVoteT, VoteHistoryByKeyT } from "types";
+
+export type UserDataT = {
+ apr: BigNumber;
+ countReveals: BigNumber;
+ countNoVotes: BigNumber;
+ countWrongVotes: BigNumber;
+ countCorrectVotes: BigNumber;
+ cumulativeCalculatedSlash: BigNumber;
+ cumulativeCalculatedSlashPercentage: BigNumber;
+ voteHistoryByKey: VoteHistoryByKeyT;
+};
+
+export type UserVoteDataT = {
+ isCommitted: boolean;
+ isRevealed: boolean;
+ encryptedVote: EncryptedVoteT | undefined;
+ decryptedVote: DecryptedVoteT | undefined;
+};
diff --git a/types/global.ts b/types/voting.ts
similarity index 50%
rename from types/global.ts
rename to types/voting.ts
index e3e7677c..eff47e0b 100644
--- a/types/global.ts
+++ b/types/voting.ts
@@ -1,21 +1,8 @@
import { VotingV2Ethers } from "@uma/contracts-frontend";
import { BigNumber } from "ethers";
-import { uniqueId } from "lodash";
-import { ReactNode } from "react";
+import { DropdownItemT, InputDataT, LinkT, UserVoteDataT } from "types";
-export type InputDataT = {
- value: string | number;
- label: string;
-};
-
-export type LinkT = {
- href: string;
- label: string;
-};
-
-export type DropdownItemT = InputDataT & {
- secondaryLabel?: string;
-};
+export type UniqueKeyT = string;
export type VoteT = PriceRequestT &
VoteHistoryDataT &
@@ -56,36 +43,6 @@ export type VoteHistoryDataT = {
voteHistory: VoteHistoryT;
};
-export type UserDataQuery = {
- users: {
- annualPercentageReturn: string;
- countReveals: string;
- countNoVotes: string;
- countWrongVotes: string;
- countCorrectVotes: string;
- cumulativeCalculatedSlash: string;
- cumulativeCalculatedSlashPercentage: string;
- votesSlashed: {
- request: { id: string };
- voted: boolean;
- correctness: boolean;
- staking: boolean;
- slashAmount: string;
- }[];
- }[];
-};
-
-export type UserDataT = {
- apr: BigNumber;
- countReveals: BigNumber;
- countNoVotes: BigNumber;
- countWrongVotes: BigNumber;
- countCorrectVotes: BigNumber;
- cumulativeCalculatedSlash: BigNumber;
- cumulativeCalculatedSlashPercentage: BigNumber;
- voteHistoryByKey: VoteHistoryByKeyT;
-};
-
export type VoteHistoryT = {
uniqueKey: UniqueKeyT;
voted: boolean;
@@ -96,28 +53,8 @@ export type VoteHistoryT = {
export type VoteHistoryByKeyT = Record;
-export type PastVotesQuery = {
- priceRequests: {
- id: string;
- identifier: {
- id: string;
- };
- time: string;
- price: string;
- ancillaryData: string;
- requestIndex: string;
- }[];
-};
-
export type PriceRequestByKeyT = Record;
-export type UserVoteDataT = {
- isCommitted: boolean;
- isRevealed: boolean;
- encryptedVote: EncryptedVoteT | undefined;
- decryptedVote: DecryptedVoteT | undefined;
-};
-
export type VoteMetaDataT = {
title: string;
description: string;
@@ -150,15 +87,22 @@ export type ContentfulDataT = {
umipLink?: string;
};
-export type ContentfulDataByKeyT = Record;
-
-export type UniqueKeyT = string;
+export type ContentfulDataByKeyT = Record<
+ UniqueKeyT,
+ ContentfulDataT | undefined
+>;
export type EncryptedVoteT = string;
-export type EncryptedVotesByKeyT = Record;
+export type EncryptedVotesByKeyT = Record<
+ UniqueKeyT,
+ EncryptedVoteT | undefined
+>;
export type DecryptedVoteT = { price: string; salt: string };
-export type DecryptedVotesByKeyT = Record;
+export type DecryptedVotesByKeyT = Record<
+ UniqueKeyT,
+ DecryptedVoteT | undefined
+>;
export type VoteExistsByKeyT = Record;
@@ -173,12 +117,6 @@ export type VoteTimelineT = {
export type VoteOriginT = "UMA" | "Polymarket";
-export type PanelTypeT = "menu" | "claim" | "vote" | "stake" | "history" | "remind" | "delegation" | null;
-
-export type VotePanelContentT = VoteT;
-
-export type PanelContentT = VotePanelContentT | null;
-
export type SigningKey = {
publicKey: string;
privateKey: string;
@@ -200,14 +138,6 @@ export type IdentifierDetailsT = {
umipLink: UmipLinkT;
};
-export type StakerDetailsT = {
- stakedBalance: BigNumber;
- pendingUnstake: BigNumber;
- canUnstakeTime: Date | undefined;
- unstakeRequestTime: Date | undefined;
- delegate: string;
-};
-
export type FormatVotesToCommit = {
votes: VoteT[];
selectedVotes: SelectedVotesByKeyT;
@@ -232,45 +162,3 @@ export type RevealVotes = {
};
export type ActivityStatusT = "active" | "upcoming" | "past";
-
-export type PaginateForT = "activeVotesPage" | "upcomingVotesPage" | "pastVotesPage" | "voteHistoryPage";
-
-export type PageStateT = {
- pageNumber: number;
- resultsPerPage: number;
-};
-
-export type PageStatesT = Record;
-
-export type UniqueIdT = ReturnType;
-
-export type NotificationT = {
- message: ReactNode;
- id: UniqueIdT;
- transactionHash?: string;
- type: "success" | "error" | "pending";
-};
-
-export type PendingNotificationT = NotificationT;
-
-export type SettledEventT = {
- message: ReactNode;
- id: UniqueIdT;
- pendingId: UniqueIdT;
-};
-
-export type DelegationStatusT =
- | "no-wallet-connected"
- | "no-delegation"
- | "delegate"
- | "delegator"
- | "delegate-pending"
- | "delegator-pending";
-
-export type DelegationEventT = {
- delegate: string;
- delegator: string;
- transactionHash: string;
-};
-
-export type ErrorOriginT = "default" | "vote" | "stake" | "unstake" | "claim" | "delegation" | "storybook";
diff --git a/web3/contracts/createVotingContractInstance.ts b/web3/contracts/createVotingContractInstance.ts
index 87a6a0ca..786a58f1 100644
--- a/web3/contracts/createVotingContractInstance.ts
+++ b/web3/contracts/createVotingContractInstance.ts
@@ -1,10 +1,13 @@
import { VotingV2Ethers__factory } from "@uma/contracts-frontend";
-import { votingContractAddress } from "constants/addresses";
+import { votingContractAddress } from "constant";
import { ethers } from "ethers";
export function createVotingContractInstance(signer?: ethers.Signer) {
if (!signer) {
- const provider = new ethers.providers.InfuraProvider("goerli", process.env.NEXT_PUBLIC_INFURA_ID);
+ const provider = new ethers.providers.InfuraProvider(
+ "goerli",
+ process.env.NEXT_PUBLIC_INFURA_ID
+ );
signer = new ethers.VoidSigner(votingContractAddress, provider);
}
return VotingV2Ethers__factory.connect(votingContractAddress, signer);
diff --git a/web3/contracts/createVotingTokenContractInstance.ts b/web3/contracts/createVotingTokenContractInstance.ts
index 6d9766aa..648e3af5 100644
--- a/web3/contracts/createVotingTokenContractInstance.ts
+++ b/web3/contracts/createVotingTokenContractInstance.ts
@@ -1,11 +1,14 @@
import { VotingTokenEthers__factory } from "@uma/contracts-frontend";
-import { votingTokenContractAddress } from "constants/addresses";
+import { votingTokenContractAddress } from "constant";
import { ethers } from "ethers";
export function createVotingTokenContractInstance(signer?: ethers.Signer) {
const address = votingTokenContractAddress;
if (!signer) {
- const provider = new ethers.providers.InfuraProvider("goerli", process.env.NEXT_PUBLIC_INFURA_ID);
+ const provider = new ethers.providers.InfuraProvider(
+ "goerli",
+ process.env.NEXT_PUBLIC_INFURA_ID
+ );
signer = new ethers.VoidSigner(address, provider);
}
return VotingTokenEthers__factory.connect(address, signer);
diff --git a/web3/mutations/delegation/removeDelegate.ts b/web3/mutations/delegation/removeDelegate.ts
index 9f6938e9..e41679d1 100644
--- a/web3/mutations/delegation/removeDelegate.ts
+++ b/web3/mutations/delegation/removeDelegate.ts
@@ -7,7 +7,11 @@ export async function removeDelegate({
notificationMessages,
}: {
voting: VotingV2Ethers;
- notificationMessages: { pending: ReactNode; success: ReactNode; error: ReactNode };
+ notificationMessages: {
+ pending: ReactNode;
+ success: ReactNode;
+ error: ReactNode;
+ };
}) {
const tx = await voting.setDelegate(zeroAddress);
return handleNotifications(tx, {
diff --git a/web3/mutations/delegation/removeDelegator.ts b/web3/mutations/delegation/removeDelegator.ts
index 3b89a2a7..61a16111 100644
--- a/web3/mutations/delegation/removeDelegator.ts
+++ b/web3/mutations/delegation/removeDelegator.ts
@@ -7,7 +7,11 @@ export async function removeDelegator({
notificationMessages,
}: {
voting: VotingV2Ethers;
- notificationMessages: { pending: ReactNode; success: ReactNode; error: ReactNode };
+ notificationMessages: {
+ pending: ReactNode;
+ success: ReactNode;
+ error: ReactNode;
+ };
}) {
const tx = await voting.setDelegator(zeroAddress);
return handleNotifications(tx, {
diff --git a/web3/mutations/delegation/setDelegate.ts b/web3/mutations/delegation/setDelegate.ts
index d1e32977..2ffeb4f0 100644
--- a/web3/mutations/delegation/setDelegate.ts
+++ b/web3/mutations/delegation/setDelegate.ts
@@ -11,7 +11,11 @@ interface SetDelegate {
error: ReactNode;
};
}
-export async function setDelegate({ voting, delegateAddress, notificationMessages }: SetDelegate) {
+export async function setDelegate({
+ voting,
+ delegateAddress,
+ notificationMessages,
+}: SetDelegate) {
const tx = await voting.setDelegate(delegateAddress);
return handleNotifications(tx, {
pending: notificationMessages.pending,
diff --git a/web3/mutations/delegation/setDelegator.ts b/web3/mutations/delegation/setDelegator.ts
index 5c37c915..2a5cc00a 100644
--- a/web3/mutations/delegation/setDelegator.ts
+++ b/web3/mutations/delegation/setDelegator.ts
@@ -5,9 +5,17 @@ import { ReactNode } from "react";
interface SetDelegator {
voting: VotingV2Ethers;
delegatorAddress: string;
- notificationMessages: { pending: ReactNode; success: ReactNode; error: ReactNode };
+ notificationMessages: {
+ pending: ReactNode;
+ success: ReactNode;
+ error: ReactNode;
+ };
}
-export async function setDelegator({ voting, delegatorAddress, notificationMessages }: SetDelegator) {
+export async function setDelegator({
+ voting,
+ delegatorAddress,
+ notificationMessages,
+}: SetDelegator) {
const tx = await voting.setDelegator(delegatorAddress);
return handleNotifications(tx, {
pending: notificationMessages.pending,
diff --git a/web3/mutations/staking/approve.ts b/web3/mutations/staking/approve.ts
index db7c4685..6ba686d8 100644
--- a/web3/mutations/staking/approve.ts
+++ b/web3/mutations/staking/approve.ts
@@ -1,5 +1,5 @@
import { VotingTokenEthers } from "@uma/contracts-frontend";
-import { votingContractAddress } from "constants/addresses";
+import { votingContractAddress } from "constant";
import { BigNumber } from "ethers";
import { formatNumberForDisplay, handleNotifications } from "helpers";
@@ -10,7 +10,10 @@ export async function approve({
votingToken: VotingTokenEthers;
approveAmount: BigNumber;
}) {
- const tx = await votingToken.functions.approve(votingContractAddress, approveAmount);
+ const tx = await votingToken.functions.approve(
+ votingContractAddress,
+ approveAmount
+ );
return handleNotifications(tx, {
pending: `Approving ${formatNumberForDisplay(approveAmount)} UMA...`,
success: `Approved ${formatNumberForDisplay(approveAmount)} UMA`,
diff --git a/web3/mutations/staking/executeUnstake.ts b/web3/mutations/staking/executeUnstake.ts
index 734d1abe..d67fca2d 100644
--- a/web3/mutations/staking/executeUnstake.ts
+++ b/web3/mutations/staking/executeUnstake.ts
@@ -11,8 +11,14 @@ export async function executeUnstake({
}) {
const tx = await voting.functions.executeUnstake();
return handleNotifications(tx, {
- pending: `Executing unstake of ${formatNumberForDisplay(pendingUnstake)} UMA...`,
- success: `Executed unstake of ${formatNumberForDisplay(pendingUnstake)} UMA`,
- error: `Failed to execute unstake of ${formatNumberForDisplay(pendingUnstake)} UMA`,
+ pending: `Executing unstake of ${formatNumberForDisplay(
+ pendingUnstake
+ )} UMA...`,
+ success: `Executed unstake of ${formatNumberForDisplay(
+ pendingUnstake
+ )} UMA`,
+ error: `Failed to execute unstake of ${formatNumberForDisplay(
+ pendingUnstake
+ )} UMA`,
});
}
diff --git a/web3/mutations/staking/requestUnstake.ts b/web3/mutations/staking/requestUnstake.ts
index 112240ac..1615b770 100644
--- a/web3/mutations/staking/requestUnstake.ts
+++ b/web3/mutations/staking/requestUnstake.ts
@@ -2,11 +2,23 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { BigNumber } from "ethers";
import { formatNumberForDisplay, handleNotifications } from "helpers";
-export async function requestUnstake({ voting, unstakeAmount }: { voting: VotingV2Ethers; unstakeAmount: BigNumber }) {
+export async function requestUnstake({
+ voting,
+ unstakeAmount,
+}: {
+ voting: VotingV2Ethers;
+ unstakeAmount: BigNumber;
+}) {
const tx = await voting.functions.requestUnstake(unstakeAmount);
return handleNotifications(tx, {
- pending: `Requesting unstake of ${formatNumberForDisplay(unstakeAmount)} UMA...`,
- success: `Requested unstake of ${formatNumberForDisplay(unstakeAmount)} UMA`,
- error: `Failed to request unstake of ${formatNumberForDisplay(unstakeAmount)} UMA`,
+ pending: `Requesting unstake of ${formatNumberForDisplay(
+ unstakeAmount
+ )} UMA...`,
+ success: `Requested unstake of ${formatNumberForDisplay(
+ unstakeAmount
+ )} UMA`,
+ error: `Failed to request unstake of ${formatNumberForDisplay(
+ unstakeAmount
+ )} UMA`,
});
}
diff --git a/web3/mutations/staking/stake.ts b/web3/mutations/staking/stake.ts
index fb0c2f82..107b3966 100644
--- a/web3/mutations/staking/stake.ts
+++ b/web3/mutations/staking/stake.ts
@@ -2,7 +2,13 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { BigNumber } from "ethers";
import { formatNumberForDisplay, handleNotifications } from "helpers";
-export async function stake({ voting, stakeAmount }: { voting: VotingV2Ethers; stakeAmount: BigNumber }) {
+export async function stake({
+ voting,
+ stakeAmount,
+}: {
+ voting: VotingV2Ethers;
+ stakeAmount: BigNumber;
+}) {
const tx = await voting.functions.stake(stakeAmount);
return handleNotifications(tx, {
diff --git a/web3/mutations/staking/withdrawAndRestake.ts b/web3/mutations/staking/withdrawAndRestake.ts
index 01e52173..0fc95e09 100644
--- a/web3/mutations/staking/withdrawAndRestake.ts
+++ b/web3/mutations/staking/withdrawAndRestake.ts
@@ -11,8 +11,14 @@ export async function withdrawAndRestake({
}) {
const tx = await voting.functions.withdrawAndRestake();
return handleNotifications(tx, {
- pending: `Withdrawing and restaking ${formatNumberForDisplay(outstandingRewards)} UMA...`,
- success: `Withdrew and restaked ${formatNumberForDisplay(outstandingRewards)} UMA`,
- error: `Failed to withdraw and restake ${formatNumberForDisplay(outstandingRewards)} UMA`,
+ pending: `Withdrawing and restaking ${formatNumberForDisplay(
+ outstandingRewards
+ )} UMA...`,
+ success: `Withdrew and restaked ${formatNumberForDisplay(
+ outstandingRewards
+ )} UMA`,
+ error: `Failed to withdraw and restake ${formatNumberForDisplay(
+ outstandingRewards
+ )} UMA`,
});
}
diff --git a/web3/mutations/staking/withdrawRewards.ts b/web3/mutations/staking/withdrawRewards.ts
index 6151578f..6ba29746 100644
--- a/web3/mutations/staking/withdrawRewards.ts
+++ b/web3/mutations/staking/withdrawRewards.ts
@@ -14,6 +14,8 @@ export async function withdrawRewards({
return handleNotifications(tx, {
pending: `Withdrawing ${formatNumberForDisplay(outstandingRewards)} UMA...`,
success: `Withdrew ${formatNumberForDisplay(outstandingRewards)} UMA`,
- error: `Failed to withdraw ${formatNumberForDisplay(outstandingRewards)} UMA`,
+ error: `Failed to withdraw ${formatNumberForDisplay(
+ outstandingRewards
+ )} UMA`,
});
}
diff --git a/web3/mutations/votes/revealVotes.ts b/web3/mutations/votes/revealVotes.ts
index 5acab255..2c3dde3a 100644
--- a/web3/mutations/votes/revealVotes.ts
+++ b/web3/mutations/votes/revealVotes.ts
@@ -5,7 +5,9 @@ export async function revealVotes({ votesToReveal, voting }: RevealVotes) {
const formattedVotes = formatVotesToReveal(votesToReveal);
if (!formattedVotes.length) return;
- const revealVoteFunctionFragment = voting.interface.getFunction("revealVote(bytes32,uint256,int256,bytes,int256)");
+ const revealVoteFunctionFragment = voting.interface.getFunction(
+ "revealVote(bytes32,uint256,int256,bytes,int256)"
+ );
const calldata = formattedVotes.flatMap((vote) => {
if (!vote) return [];
diff --git a/web3/queries/balances/getOutstandingRewards.ts b/web3/queries/balances/getOutstandingRewards.ts
index 8bd7dff0..6b48edca 100644
--- a/web3/queries/balances/getOutstandingRewards.ts
+++ b/web3/queries/balances/getOutstandingRewards.ts
@@ -1,6 +1,9 @@
import { VotingV2Ethers } from "@uma/contracts-frontend";
-export async function getOutstandingRewards(votingContract: VotingV2Ethers, address: string) {
+export async function getOutstandingRewards(
+ votingContract: VotingV2Ethers,
+ address: string
+) {
const result = await votingContract.functions.outstandingRewards(address);
return result?.[0];
}
diff --git a/web3/queries/balances/getStakerDetails.ts b/web3/queries/balances/getStakerDetails.ts
index b6f54495..f5acd864 100644
--- a/web3/queries/balances/getStakerDetails.ts
+++ b/web3/queries/balances/getStakerDetails.ts
@@ -2,12 +2,23 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { getCanUnstakeTime } from "helpers";
import { getUnstakeCoolDown } from "./getUnstakeCoolDown";
-export async function getStakerDetails(votingContract: VotingV2Ethers, address: string) {
+export async function getStakerDetails(
+ votingContract: VotingV2Ethers,
+ address: string
+) {
const result = await votingContract.voterStakes(address);
const { unstakeCoolDown } = await getUnstakeCoolDown(votingContract);
- const { stake: stakedBalance, pendingUnstake, unstakeRequestTime, delegate } = result ?? {};
+ const {
+ stake: stakedBalance,
+ pendingUnstake,
+ unstakeRequestTime,
+ delegate,
+ } = result ?? {};
const unstakeRequestTimeAsDate = new Date(Number(unstakeRequestTime) * 1000);
- const canUnstakeTime = getCanUnstakeTime(unstakeRequestTimeAsDate, unstakeCoolDown);
+ const canUnstakeTime = getCanUnstakeTime(
+ unstakeRequestTimeAsDate,
+ unstakeCoolDown
+ );
return {
stakedBalance,
diff --git a/web3/queries/balances/getTokenAllowance.ts b/web3/queries/balances/getTokenAllowance.ts
index e8326c82..e9f10fbb 100644
--- a/web3/queries/balances/getTokenAllowance.ts
+++ b/web3/queries/balances/getTokenAllowance.ts
@@ -1,7 +1,13 @@
import { VotingTokenEthers } from "@uma/contracts-frontend";
-import { votingContractAddress } from "constants/addresses";
+import { votingContractAddress } from "constant";
-export async function getTokenAllowance(votingTokenContract: VotingTokenEthers, address: string) {
- const result = await votingTokenContract.functions.allowance(address, votingContractAddress);
+export async function getTokenAllowance(
+ votingTokenContract: VotingTokenEthers,
+ address: string
+) {
+ const result = await votingTokenContract.functions.allowance(
+ address,
+ votingContractAddress
+ );
return result?.[0];
}
diff --git a/web3/queries/balances/getUnstakedBalance.ts b/web3/queries/balances/getUnstakedBalance.ts
index ab8af743..298d68ab 100644
--- a/web3/queries/balances/getUnstakedBalance.ts
+++ b/web3/queries/balances/getUnstakedBalance.ts
@@ -1,6 +1,9 @@
import { VotingTokenEthers } from "@uma/contracts-frontend";
-export async function getUnstakedBalance(votingTokenContract: VotingTokenEthers, address: string) {
+export async function getUnstakedBalance(
+ votingTokenContract: VotingTokenEthers,
+ address: string
+) {
const result = await votingTokenContract.functions.balanceOf(address);
return result?.[0];
}
diff --git a/web3/queries/delegation/getDelegateSetEvents.ts b/web3/queries/delegation/getDelegateSetEvents.ts
index 59f56941..cfe98d02 100644
--- a/web3/queries/delegation/getDelegateSetEvents.ts
+++ b/web3/queries/delegation/getDelegateSetEvents.ts
@@ -32,13 +32,19 @@ async function removeDanglingDelegateEvents(
) {
const result = [];
for (const event of events) {
- const stillWantToBeDelegator = await detectDanglingDelegate(voting, event.delegator);
+ const stillWantToBeDelegator = await detectDanglingDelegate(
+ voting,
+ event.delegator
+ );
if (stillWantToBeDelegator) result.push(event);
}
return result;
}
-async function detectDanglingDelegate(voting: VotingV2Ethers, delegator: string) {
+async function detectDanglingDelegate(
+ voting: VotingV2Ethers,
+ delegator: string
+) {
const { delegate } = await getStakerDetails(voting, delegator);
if (delegate === zeroAddress) return false;
return true;
diff --git a/web3/queries/delegation/getDelegateToStaker.ts b/web3/queries/delegation/getDelegateToStaker.ts
index f7b31369..069841ac 100644
--- a/web3/queries/delegation/getDelegateToStaker.ts
+++ b/web3/queries/delegation/getDelegateToStaker.ts
@@ -1,5 +1,8 @@
import { VotingV2Ethers } from "@uma/contracts-frontend";
-export function getDelegateToStaker(voting: VotingV2Ethers, delegateAddress: string) {
+export function getDelegateToStaker(
+ voting: VotingV2Ethers,
+ delegateAddress: string
+) {
return voting.delegateToStaker(delegateAddress);
}
diff --git a/web3/queries/delegation/getIgnoredRequestToBeDelegateAddresses.ts b/web3/queries/delegation/getIgnoredRequestToBeDelegateAddresses.ts
index 39c9084b..79f1c0ad 100644
--- a/web3/queries/delegation/getIgnoredRequestToBeDelegateAddresses.ts
+++ b/web3/queries/delegation/getIgnoredRequestToBeDelegateAddresses.ts
@@ -1,7 +1,10 @@
import { getIgnoredRequestToBeDelegateAddressesFromStorage } from "helpers";
-export function getIgnoredRequestToBeDelegateAddresses(ignoredByAddress: string) {
- const ignoredRequestToBeDelegateAddresses = getIgnoredRequestToBeDelegateAddressesFromStorage();
+export function getIgnoredRequestToBeDelegateAddresses(
+ ignoredByAddress: string
+) {
+ const ignoredRequestToBeDelegateAddresses =
+ getIgnoredRequestToBeDelegateAddressesFromStorage();
return ignoredRequestToBeDelegateAddresses[ignoredByAddress] ?? [];
}
diff --git a/web3/queries/votes/getCommittedVotes.ts b/web3/queries/votes/getCommittedVotes.ts
index 99e82e51..c267e8ce 100644
--- a/web3/queries/votes/getCommittedVotes.ts
+++ b/web3/queries/votes/getCommittedVotes.ts
@@ -2,14 +2,29 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { decodeHexString, makeUniqueKeyForVote } from "helpers";
import { VoteExistsByKeyT } from "types";
-export async function getCommittedVotes(votingContract: VotingV2Ethers, address: string, roundId: number) {
- const filter = votingContract.filters.VoteCommitted(address, null, null, null, null, null);
+export async function getCommittedVotes(
+ votingContract: VotingV2Ethers,
+ address: string,
+ roundId: number
+) {
+ const filter = votingContract.filters.VoteCommitted(
+ address,
+ null,
+ null,
+ null,
+ null,
+ null
+ );
const result = await votingContract.queryFilter(filter);
- const eventData = result?.map(({ args }) => args).filter((args) => args.roundId.toNumber() === roundId);
+ const eventData = result
+ ?.map(({ args }) => args)
+ .filter((args) => args.roundId.toNumber() === roundId);
const committedVotes: VoteExistsByKeyT = {};
eventData?.forEach(({ identifier, time, ancillaryData }) => {
const decodedIdentifier = decodeHexString(identifier);
- committedVotes[makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)] = true;
+ committedVotes[
+ makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)
+ ] = true;
});
return committedVotes;
}
diff --git a/web3/queries/votes/getEncryptedVotes.ts b/web3/queries/votes/getEncryptedVotes.ts
index 74c63fbc..f03fc0de 100644
--- a/web3/queries/votes/getEncryptedVotes.ts
+++ b/web3/queries/votes/getEncryptedVotes.ts
@@ -2,15 +2,28 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { decodeHexString, makeUniqueKeyForVote } from "helpers";
import { EncryptedVotesByKeyT } from "types";
-export async function getEncryptedVotes(votingContract: VotingV2Ethers, address: string, roundId: number) {
- const filter = votingContract.filters.EncryptedVote(address, roundId, null, null, null, null);
+export async function getEncryptedVotes(
+ votingContract: VotingV2Ethers,
+ address: string,
+ roundId: number
+) {
+ const filter = votingContract.filters.EncryptedVote(
+ address,
+ roundId,
+ null,
+ null,
+ null,
+ null
+ );
const result = await votingContract.queryFilter(filter);
const eventData = result?.map(({ args }) => args);
const encryptedVotes: EncryptedVotesByKeyT = {};
eventData?.forEach(({ encryptedVote, identifier, time, ancillaryData }) => {
const decodedIdentifier = decodeHexString(identifier);
- encryptedVotes[makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)] = encryptedVote;
+ encryptedVotes[
+ makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)
+ ] = encryptedVote;
});
return encryptedVotes;
diff --git a/web3/queries/votes/getRevealedVotes.ts b/web3/queries/votes/getRevealedVotes.ts
index bbb01a29..863c950a 100644
--- a/web3/queries/votes/getRevealedVotes.ts
+++ b/web3/queries/votes/getRevealedVotes.ts
@@ -2,15 +2,32 @@ import { VotingV2Ethers } from "@uma/contracts-frontend";
import { decodeHexString, makeUniqueKeyForVote } from "helpers";
import { VoteExistsByKeyT } from "types";
-export async function getRevealedVotes(votingContract: VotingV2Ethers, address: string, roundId: number) {
- const filter = votingContract.filters.VoteRevealed(address, null, null, null, null, null, null, null);
+export async function getRevealedVotes(
+ votingContract: VotingV2Ethers,
+ address: string,
+ roundId: number
+) {
+ const filter = votingContract.filters.VoteRevealed(
+ address,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ );
const result = await votingContract.queryFilter(filter);
- const eventData = result?.map(({ args }) => args).filter((args) => args.roundId.toNumber() === roundId);
+ const eventData = result
+ ?.map(({ args }) => args)
+ .filter((args) => args.roundId.toNumber() === roundId);
const revealedVotes: VoteExistsByKeyT = {};
eventData?.forEach(({ identifier, time, ancillaryData }) => {
const decodedIdentifier = decodeHexString(identifier);
- revealedVotes[makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)] = true;
+ revealedVotes[
+ makeUniqueKeyForVote(decodedIdentifier, time, ancillaryData)
+ ] = true;
});
return revealedVotes;
diff --git a/web3/queries/votes/getUpcomingVotes.ts b/web3/queries/votes/getUpcomingVotes.ts
index eab25e51..249540bf 100644
--- a/web3/queries/votes/getUpcomingVotes.ts
+++ b/web3/queries/votes/getUpcomingVotes.ts
@@ -1,12 +1,17 @@
import { VotingV2Ethers } from "@uma/contracts-frontend";
-import { goerliDeployBlock } from "constants/deployBlocks";
+import { goerliDeployBlock } from "constant";
import { makePriceRequestsByKey } from "helpers";
-export async function getUpcomingVotes(voting: VotingV2Ethers, roundId: number) {
+export async function getUpcomingVotes(
+ voting: VotingV2Ethers,
+ roundId: number
+) {
const filter = voting.filters.PriceRequestAdded(null, null, null);
const result = await voting.queryFilter(filter, goerliDeployBlock);
const eventData = result?.map(({ args }) => args);
- const onlyUpcoming = eventData?.filter((event) => event.roundId.toNumber() > roundId);
+ const onlyUpcoming = eventData?.filter(
+ (event) => event.roundId.toNumber() > roundId
+ );
const upcomingVotes = makePriceRequestsByKey(onlyUpcoming);
const hasUpcomingVotes = Object.keys(upcomingVotes).length > 0;
diff --git a/web3/queries/votes/getVoteTransactionHashes.ts b/web3/queries/votes/getVoteTransactionHashes.ts
index 4d7a8494..d7ce84e6 100644
--- a/web3/queries/votes/getVoteTransactionHashes.ts
+++ b/web3/queries/votes/getVoteTransactionHashes.ts
@@ -1,15 +1,20 @@
import { VotingV2Ethers } from "@uma/contracts-frontend";
-import { goerliDeployBlock } from "constants/deployBlocks";
+import { goerliDeployBlock } from "constant";
import { PriceRequestByKeyT, UniqueKeyT } from "types";
-export async function getVoteTransactionHashes(voting: VotingV2Ethers, allVotesByKey: PriceRequestByKeyT) {
+export async function getVoteTransactionHashes(
+ voting: VotingV2Ethers,
+ allVotesByKey: PriceRequestByKeyT
+) {
const filter = voting.filters.PriceRequestAdded(null, null, null);
const events = await voting.queryFilter(filter, goerliDeployBlock);
const voteTransactionHashesByKey: Record = {};
for (const [uniqueKey, vote] of Object.entries(allVotesByKey)) {
- const eventForVote = events.find((event) => event?.args?.priceRequestIndex?.eq(vote.voteNumber));
+ const eventForVote = events.find((event) =>
+ event?.args?.priceRequestIndex?.eq(vote.voteNumber)
+ );
const transactionHash = eventForVote?.transactionHash || "rolled";
voteTransactionHashesByKey[uniqueKey] = transactionHash;