Skip to content

Commit a0ed037

Browse files
committed
Show alert when trying to Deauth during Taco commitment period
1 parent 0551ab5 commit a0ed037

File tree

1 file changed

+22
-2
lines changed
  • src/pages/Staking/AuthorizeStakingApps/AuthorizeApplicationsCardCheckbox

1 file changed

+22
-2
lines changed

src/pages/Staking/AuthorizeStakingApps/AuthorizeApplicationsCardCheckbox/index.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { formatDate } from "../../../../utils/date"
3535
import { calculatePercenteage } from "../../../../utils/percentage"
3636
import { StakingAppForm } from "../../../../components/StakingApplicationForms"
3737
import { AuthorizationStatus } from "../../../../types"
38+
import { StakingProviderInfo } from "../../../../threshold-ts/applications"
3839

3940
interface CommonProps {
4041
stakingAppId: StakingAppName
@@ -58,6 +59,7 @@ type StakingAppAuthDataBaseProps = {
5859
remainingAuthorizationDecreaseDelay: string
5960
isOperatorInPool: boolean | undefined
6061
operator: string
62+
stakingProviderInfo?: StakingProviderInfo | undefined
6163
}
6264

6365
type AppAuthDataConditionalProps =
@@ -255,8 +257,26 @@ export const AuthorizeApplicationsCardCheckboxBase: FC<
255257
}
256258

257259
const onSubmitForm = (tokenAmount: string) => {
258-
if (isIncreaseAction) onAuthorizeApp(tokenAmount)
259-
else onInitiateDeauthorization(tokenAmount)
260+
if (isIncreaseAction) {
261+
onAuthorizeApp(tokenAmount)
262+
} else {
263+
if (appAuthData.stakingAppId === "taco") {
264+
// const endCommitment = appAuthData.stakingProviderInfo?.endCommitment
265+
const endCommitment = appAuthData.stakingProviderInfo?.endCommitment
266+
const currentTime = Math.floor(Date.now() / 1000)
267+
const isCommited = (Number(endCommitment) ?? 0) > currentTime
268+
const endCommitmentDate = new Date(
269+
(Number(endCommitment) ?? 0) * 1000
270+
).toLocaleDateString()
271+
if (isCommited) {
272+
alert(`You are still committed until ${endCommitmentDate}.`)
273+
} else {
274+
onInitiateDeauthorization(tokenAmount)
275+
}
276+
} else {
277+
onInitiateDeauthorization(tokenAmount)
278+
}
279+
}
260280
}
261281

262282
const onConfirmDeauthorization = () => {

0 commit comments

Comments
 (0)