Skip to content

Commit

Permalink
add time left stake-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
karlavasquez8 committed Apr 25, 2024
1 parent 6cbcec3 commit 815ddfb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/nextjs/components/stake/StakeContractInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,7 @@ import { useScaffoldContractRead } from "~~/hooks/scaffold-stark/useScaffoldCont
import { useScaffoldContractWrite } from "~~/hooks/scaffold-stark/useScaffoldContractWrite";
import { ETHToPrice } from "~~/components/stake/ETHToPrice";
import { Address } from "~~/components/scaffold-stark";

function humanizeDuration(seconds: number) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = Math.floor(seconds % 60);

const formattedHours = hours > 0 ? `${hours}h ` : "";
const formattedMinutes = minutes > 0 ? `${minutes}m ` : "";
const formattedSecs = secs > 0 ? `${secs}s` : "";

return `${formattedHours}${formattedMinutes}${formattedSecs}`;
}
import humanizeDuration from "humanize-duration";

const wrapInTryCatch =
(fn: () => Promise<any>, errorMessageFnDescription: string) => async () => {
Expand Down Expand Up @@ -67,7 +56,7 @@ export const StakeContractInteraction = () => {
const { data: myStake } = useScaffoldContractRead({
contractName: "Challenge1",
functionName: "balances",
args: [connectedAddress],
args: [connectedAddress ?? ""],
watch: true,
});

Expand All @@ -85,7 +74,6 @@ export const StakeContractInteraction = () => {
contractName: "Challenge1",
functionName: "withdraw",
});

return (
<div className="flex items-center flex-col flex-grow w-full px-4 gap-12">
{isStakingCompleted && (
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"zustand": "^4.1.2"
},
"devDependencies": {
"@types/humanize-duration": "^3.27.4",
"@types/node": "^20",
"@types/nprogress": "^0",
"@types/react": "^18",
Expand Down

0 comments on commit 815ddfb

Please sign in to comment.