Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Jan 22, 2024
1 parent 7becbfd commit 973e073
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions apps/nextjs/src/app/staking/StakingContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ export const StakingContainer = () => {

const address = addressL1 ? addressL1.toLowerCase() : "0x";

useEffect(() => {
if (addressL1) {
fetch(`/api/staking/${addressL1}`)
.then((res) => res.json())
.then((data) => {
console.log(data);
setHexProof(data.proof);
data.amount && setPoolTotal(parseEther(data.amount?.toString()));
});
}
}, [addressL1]);

const { data: realmsData, isLoading: realmsDataIsLoading } = useQuery({
queryKey: ["UsersRealms" + address],
queryFn: async () =>
Expand Down Expand Up @@ -116,7 +104,7 @@ export const StakingContainer = () => {
isLoading: poolWithdrawalsLoading,
isFetched,
} = useReadContract({
address: stakingAddresses[NETWORK_NAME].paymentPool as `0x${string}`,
address: stakingAddresses["MAIN"].paymentPool as `0x${string}`,
abi: paymentPoolAbi,
functionName: "withdrawals",
args: [address as `0x${string}`],
Expand All @@ -126,6 +114,15 @@ export const StakingContainer = () => {
console.log(poolTotal);

useEffect(() => {
if (addressL1) {
fetch(`/api/staking/${addressL1}`)
.then((res) => res.json())
.then((data) => {
console.log(data);
setHexProof(data.proof);
data.amount && setPoolTotal(parseEther(data.amount?.toString()));
});
}
if (isFetched && poolWithdrawlsData && !calculatedPoolAmount && poolTotal) {
console.log("poolWithdrawlsData", poolWithdrawlsData);
const claimable = poolTotal - poolWithdrawlsData;
Expand Down

0 comments on commit 973e073

Please sign in to comment.