Skip to content

Commit

Permalink
Feat/call get oat eligibility and show galxe link (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
elihylui authored Aug 24, 2023
1 parent 33c865e commit b3ffe67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Binary file modified build/bin/main.bin
Binary file not shown.
15 changes: 11 additions & 4 deletions src/renderer/components/Task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useNavigate } from 'react-router-dom';
import { formatUnits } from 'viem';
import { useTaskData } from 'renderer/hooks/useTaskData';
import { TaskType } from './types';
import { web3AuthInstance } from '../Web3AuthInstance';

interface TaskProps {
task: TaskType;
Expand Down Expand Up @@ -86,6 +87,7 @@ function Task({ task, goBack }: TaskProps) {
finalDataForReport,
dataCurrentAccuracy,
accuracies,
isEligibleForOAT
currentNumberOfParticipants,
} = useTaskData({
task,
Expand Down Expand Up @@ -328,12 +330,12 @@ function Task({ task, goBack }: TaskProps) {
}, [isRunning]);

useEffect(() => {
if (isTrainingCompleted) {
if (isTrainingCompleted && address && task && task.address) {
setShowCompletedModal(true);
setStep('REPORT');
}
}, [isTrainingCompleted]);

}, [isTrainingCompleted, address, task]);
return (
<>
{showCompletedModal && (
Expand All @@ -346,7 +348,7 @@ function Task({ task, goBack }: TaskProps) {
pad="medium"
align="center"
gap="small"
width="medium"
width="large"
height="medium"
>
<Box
Expand All @@ -369,6 +371,11 @@ function Task({ task, goBack }: TaskProps) {
<Box align="start">
<Text size="medium">FLock Reward: {totalRewardedAmount}</Text>
<Text size="medium">Final Accuracy: {Number(dataCurrentAccuracy)} </Text>
{isEligibleForOAT && (
<Text size='medium'>You are eligible for an OAT on Galxe!
Claim <a href="https://galxe.com/flock/" target="_blank" rel="noopener noreferrer"> here</a>.
</Text>
)}
</Box>
</Box>
</Layer>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function Wallet() {
body: JSON.stringify({ pubKey: publicKey, email: user.email, wallet: address }),
});

console.log(res, "success!")
return res.json();

} catch (error) {
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/hooks/useTaskData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ export const useTaskData = ({
});
}

const { data: isEligibleForOAT } = useContractRead({
address: task.address as `0x${string}`,
abi: FLOCK_TASK_ABI,
functionName: 'isEligibleForOAT',
args: [participantAddress],
watch: true,
}) as { data: boolean };

return {
dataCurrentRound,
dataStakedBalance,
Expand All @@ -179,6 +187,7 @@ export const useTaskData = ({
finalDataForReport,
dataCurrentAccuracy,
accuracies,
isEligibleForOAT
currentNumberOfParticipants,
};
};
Expand Down

0 comments on commit b3ffe67

Please sign in to comment.