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

Add TACo commitment checks and alerts when topping up or de-authing #724

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { formatDate } from "../../../../utils/date"
import { calculatePercenteage } from "../../../../utils/percentage"
import { StakingAppForm } from "../../../../components/StakingApplicationForms"
import { AuthorizationStatus } from "../../../../types"
import { StakingProviderInfo } from "../../../../threshold-ts/applications"

interface CommonProps {
stakingAppId: StakingAppName
Expand All @@ -58,6 +59,7 @@ type StakingAppAuthDataBaseProps = {
remainingAuthorizationDecreaseDelay: string
isOperatorInPool: boolean | undefined
operator: string
stakingProviderInfo?: StakingProviderInfo | undefined
}

type AppAuthDataConditionalProps =
Expand Down Expand Up @@ -255,8 +257,26 @@ export const AuthorizeApplicationsCardCheckboxBase: FC<
}

const onSubmitForm = (tokenAmount: string) => {
if (isIncreaseAction) onAuthorizeApp(tokenAmount)
else onInitiateDeauthorization(tokenAmount)
if (isIncreaseAction) {
onAuthorizeApp(tokenAmount)
} else {
if (appAuthData.stakingAppId === "taco") {
// const endCommitment = appAuthData.stakingProviderInfo?.endCommitment
const endCommitment = appAuthData.stakingProviderInfo?.endCommitment
const currentTime = Math.floor(Date.now() / 1000)
const isCommited = (Number(endCommitment) ?? 0) > currentTime
const endCommitmentDate = new Date(
(Number(endCommitment) ?? 0) * 1000
).toLocaleDateString()
if (isCommited) {
alert(`You are still committed until ${endCommitmentDate}.`)
theref marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@kpyszkowski kpyszkowski Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you consider using Toast component here?
Native browser alert doesn't look good and dffers in behaviour in various browsers.

} else {
onInitiateDeauthorization(tokenAmount)
}
} else {
onInitiateDeauthorization(tokenAmount)
}
}
}

const onConfirmDeauthorization = () => {
Expand Down
Loading