Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

OCT-1287: Remove code related to GLM claiming from client #30

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions client/src/api/calls/glmClaim.ts

This file was deleted.

8 changes: 2 additions & 6 deletions client/src/api/errorMessages/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Query } from '@tanstack/react-query';

import { ROOTS, QUERY_KEYS } from 'api/queryKeys';
import { ROOTS } from 'api/queryKeys';
import i18n from 'i18n';
import toastService from 'services/toastService';

import { QueryMutationError, QueryMutationErrorConfig, IgnoredQueries } from './types';

const IGNORED_QUERIES: IgnoredQueries = [
ROOTS.cryptoValues,
ROOTS.proposalsIpfsResults,
QUERY_KEYS.glmClaimCheck[0],
];
const IGNORED_QUERIES: IgnoredQueries = [ROOTS.cryptoValues, ROOTS.proposalsIpfsResults];

const errors: QueryMutationErrorConfig = {
4001: {
Expand Down
8 changes: 2 additions & 6 deletions client/src/api/errorMessages/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryKeys, Root } from 'api/queryKeys/types';
import { Root } from 'api/queryKeys/types';

export type QueryMutationError = {
message: string;
Expand All @@ -10,8 +10,4 @@ export type QueryMutationErrorConfig = {
[key: string]: QueryMutationError;
};

export type IgnoredQueries = [
Root['cryptoValues'],
Root['proposalsIpfsResults'],
QueryKeys['glmClaimCheck'][0],
];
export type IgnoredQueries = [Root['cryptoValues'], Root['proposalsIpfsResults']];
1 change: 0 additions & 1 deletion client/src/api/queryKeys/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const QUERY_KEYS: QueryKeys = {
epochUnusedRewards: epoch => [ROOTS.epochUnusedRewards, epoch.toString()],
epochesEndTime: epochNumber => [ROOTS.epochesEndTime, epochNumber.toString()],
estimatedEffectiveDeposit: userAddress => [ROOTS.estimatedEffectiveDeposit, userAddress],
glmClaimCheck: ['glmClaimCheck'],
history: ['history'],
individualProposalRewards: ['individualProposalRewards'],
individualReward: epochNumber => [ROOTS.individualReward, epochNumber.toString()],
Expand Down
1 change: 0 additions & 1 deletion client/src/api/queryKeys/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export type QueryKeys = {
epochUnusedRewards: (epoch: number) => [Root['epochUnusedRewards'], string];
epochesEndTime: (epochNumber: number) => [Root['epochesEndTime'], string];
estimatedEffectiveDeposit: (userAddress: string) => [Root['estimatedEffectiveDeposit'], string];
glmClaimCheck: ['glmClaimCheck'];
history: ['history'];
individualProposalRewards: ['individualProposalRewards'];
individualReward: (epochNumber: number) => [Root['individualReward'], string];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@
background: $color-octant-grey8;
overflow: hidden;

&.claimGlm {
padding: 6rem 0 4.4rem;

@media #{$desktop-up} {
padding: 7.2rem 0 6.4rem;
}
}

&.welcomeToOctant {
padding: 3.2rem 0 5.2rem;

Expand Down Expand Up @@ -124,8 +116,3 @@
align-items: center;
justify-content: center;
}

.buttonClaimGlm {
width: 100%;
margin-top: 4.8rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const ModalOnboarding: FC = () => {
const [currentStepIndex, setCurrentStepIndex] = useState<number>(0);
const [isUserTOSAcceptedInitial] = useState(isUserTOSAccepted);

const stepsToUse = useOnboardingSteps(isUserTOSAcceptedInitial, isOnboardingDone, () =>
setCurrentStepIndex(prev => prev + 1),
);
const stepsToUse = useOnboardingSteps(isUserTOSAcceptedInitial);

useEffect(() => {
if (isUserTOSAccepted !== undefined && !isUserTOSAccepted) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

48 changes: 2 additions & 46 deletions client/src/hooks/helpers/useOnboardingSteps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
import React, { Fragment } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useTranslation } from 'react-i18next';

import styles from 'components/shared/ModalOnboarding/ModalOnboarding.module.scss';
import { Step } from 'components/shared/ModalOnboarding/types';
import ModalOnboardingButtonClaimGlm from 'components/shared/ModalOnboardingButtonClaimGlm';
import ModalOnboardingTOS from 'components/shared/ModalOnboardingTOS';
import useGlmClaim from 'hooks/mutations/useGlmClaim';
import useGlmClaimCheck from 'hooks/queries/useGlmClaimCheck';
import useIsDecisionWindowOpen from 'hooks/queries/useIsDecisionWindowOpen';
import { formatUnitsBigInt } from 'utils/formatUnitsBigInt';

import { stepsDecisionWindowOpen, stepsDecisionWindowClosed } from './steps';

const useOnboardingSteps = (
isUserTOSAcceptedInitial: boolean | undefined,
isOnboardingDone: boolean,
onGlmClaimSuccess: () => void,
): Step[] => {
const useOnboardingSteps = (isUserTOSAcceptedInitial: boolean | undefined): Step[] => {
const { i18n } = useTranslation();

const { data: isDecisionWindowOpen } = useIsDecisionWindowOpen();
const { data: glmClaimCheck, isError, isFetched } = useGlmClaimCheck(isOnboardingDone);
const glmClaimMutation = useGlmClaim(glmClaimCheck?.value, { onSuccess: onGlmClaimSuccess });

const isUserToClaimAvailable = isFetched && !isError && !!glmClaimCheck;
const isUserEligibleToClaimFetched = isUserToClaimAvailable || (isFetched && isError);
// Status code 200 & value 0 is an indication that user already claimed.
const isUserEligibleToClaimGlm = isUserToClaimAvailable && glmClaimCheck.value !== 0n;

if (!isUserEligibleToClaimFetched) {
// We need to fetch data about claiming first.
return [];
}

return [
...(isUserTOSAcceptedInitial === false
Expand All @@ -48,29 +27,6 @@ const useOnboardingSteps = (
},
]
: []),
...(isUserEligibleToClaimGlm && glmClaimCheck?.value
? [
{
header: i18n.t('views.onboarding.stepsCommon.claimGlm.header'),
image: 'images/tip-withdraw.webp',
imageClassName: styles.claimGlm,
text: (
<Fragment>
<Trans
i18nKey="views.onboarding.stepsCommon.claimGlm.text"
values={{
value: parseInt(formatUnitsBigInt(glmClaimCheck.value), 10).toString(),
}}
/>
<ModalOnboardingButtonClaimGlm
className={styles.buttonClaimGlm}
glmClaimMutation={glmClaimMutation}
/>
</Fragment>
),
},
]
: []),
...(isDecisionWindowOpen ? stepsDecisionWindowOpen : stepsDecisionWindowClosed),
];
};
Expand Down
40 changes: 0 additions & 40 deletions client/src/hooks/mutations/useGlmClaim.ts

This file was deleted.

31 changes: 0 additions & 31 deletions client/src/hooks/queries/useGlmClaimCheck.ts

This file was deleted.

9 changes: 0 additions & 9 deletions client/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,6 @@
"usingTheApp": {
"header": "Using the app",
"text": "Before we can go any further, please read the terms of service and click the checkbox below to agree with them."
},
"claimGlm": {
"header": "Claim your GLM",
"text": "As you hold an Epoch Zero Token and you participated in the Snapshot vote, you are eligible to claim {{value}} GLM. Click the button below to withdraw to your wallet.",
"buttonLabel": {
"withdraw": "Withdraw GLM",
"withdrawn": "GLM claimed"
},
"signMessage": "Claim {{value}} GLMs"
}
},
"stepsDecisionWindowOpen": {
Expand Down
Loading