-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet-dashboard): style selected stake (#3832)
* feat(tooling-dashboard): style selected stake * feat(tooling-dashboard): add data to stake details page * feat(wallet-dashboard): remove extra memo. * feat(staking): refactor StakeDialog. Add new Layout component. * feat(tooling-core): add clsx dependency to package.json and update pnpm-lock.yaml * feat(wallet-dashboard): manage view for dialog outside. * feat(wallet-dashboard): join changes from PR 3854 * feat(wallet-dashboard): join enter amount screen from PR 3874 * feat(tooling-core): move validation schema * feat(wallet-dashboard): integrate Formik * feat(wallet-dashboard): enhance StakeDialog and EnterAmountView with FormValues integration * feat(wallet-dashboard): update StakeDialog to support selectedValidator and optional setView * feat(wallet-dashboard): refactor StakedInfo and Validator components to use core hooks and clean up imports * feat(wallet-dashboard): move useStakeTxnInfo hook to the core * fix(tooling-core): downgrade bignumber.js to 9.1.1 and yup to 1.1.1 * refactor(tooling-dashboard): change export to default and clean up code structure * refactor(wallet-dashboard): simplify validator info retrieval and add utility for total stake calculation * refactor(wallet-dashboard): streamline stake calculations and integrate new validator details utility * refactor(wallet, core): update import paths for consistency and clarity * refactor(wallet-dashboard): integrate FormikProvider. Polish interfaces. * feat(wallet-dashboard): refactor staking dialog management for home * feat(wallet-dashboard): move constants to another folder. * feat(wallet-dashboard): enhance transaction handling and improve user feedback * fix(wallet-dashboard): update onBack handler for improved navigation * refactor(wallet-dashboard): simplify import paths by removing redundant index references * fix(wallet-dashboard): update tooltip text for total staked information * refactor(core): remove unused totalValidatorStake utility function * feat(wallet-dashboard): add totalStakeOriginal to staking details and update calculations in UnstakeView * refactor(wallet): remove debug log for coinBalance in UnstakeForm --------- Co-authored-by: Bran <[email protected]> Co-authored-by: JCNoguera <[email protected]> Co-authored-by: cpl121 <[email protected]>
- Loading branch information
1 parent
15f6ea6
commit 3662450
Showing
32 changed files
with
860 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { | ||
useGetTimeBeforeEpochNumber, | ||
useTimeAgo, | ||
TimeUnit, | ||
NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE, | ||
NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_STARTS, | ||
} from '../../'; | ||
|
||
export function useStakeTxnInfo(startEpoch?: string | number) { | ||
const startEarningRewardsEpoch = | ||
Number(startEpoch || 0) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_STARTS; | ||
|
||
const redeemableRewardsEpoch = | ||
Number(startEpoch || 0) + NUM_OF_EPOCH_BEFORE_STAKING_REWARDS_REDEEMABLE; | ||
|
||
const { data: timeBeforeStakeRewardsStarts } = | ||
useGetTimeBeforeEpochNumber(startEarningRewardsEpoch); | ||
const timeBeforeStakeRewardsStartsAgo = useTimeAgo({ | ||
timeFrom: timeBeforeStakeRewardsStarts, | ||
shortedTimeLabel: false, | ||
shouldEnd: true, | ||
maxTimeUnit: TimeUnit.ONE_HOUR, | ||
}); | ||
const stakedRewardsStartEpoch = | ||
timeBeforeStakeRewardsStarts > 0 | ||
? `in ${timeBeforeStakeRewardsStartsAgo}` | ||
: startEpoch | ||
? `Epoch #${Number(startEarningRewardsEpoch)}` | ||
: '--'; | ||
|
||
const { data: timeBeforeStakeRewardsRedeemable } = | ||
useGetTimeBeforeEpochNumber(redeemableRewardsEpoch); | ||
const timeBeforeStakeRewardsRedeemableAgo = useTimeAgo({ | ||
timeFrom: timeBeforeStakeRewardsRedeemable, | ||
shortedTimeLabel: false, | ||
shouldEnd: true, | ||
maxTimeUnit: TimeUnit.ONE_HOUR, | ||
}); | ||
const timeBeforeStakeRewardsRedeemableAgoDisplay = | ||
timeBeforeStakeRewardsRedeemable > 0 | ||
? `in ${timeBeforeStakeRewardsRedeemableAgo}` | ||
: startEpoch | ||
? `Epoch #${Number(redeemableRewardsEpoch)}` | ||
: '--'; | ||
|
||
return { | ||
stakedRewardsStartEpoch, | ||
timeBeforeStakeRewardsRedeemableAgoDisplay, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { useIotaClientQuery } from '@iota/dapp-kit'; | ||
import { useGetValidatorsApy } from '../'; | ||
|
||
export function useValidatorInfo({ validatorAddress }: { validatorAddress: string }) { | ||
const { | ||
data: system, | ||
isPending: isPendingValidators, | ||
isError: errorValidators, | ||
} = useIotaClientQuery('getLatestIotaSystemState'); | ||
const { data: rollingAverageApys } = useGetValidatorsApy(); | ||
|
||
const validatorSummary = | ||
system?.activeValidators.find((validator) => validator.iotaAddress === validatorAddress) || | ||
null; | ||
|
||
const currentEpoch = Number(system?.epoch || 0); | ||
|
||
const stakingPoolActivationEpoch = Number(validatorSummary?.stakingPoolActivationEpoch || 0); | ||
|
||
// flag as new validator if the validator was activated in the last epoch | ||
// for genesis validators, this will be false | ||
const newValidator = currentEpoch - stakingPoolActivationEpoch <= 1 && currentEpoch !== 0; | ||
|
||
// flag if the validator is at risk of being removed from the active set | ||
const isAtRisk = system?.atRiskValidators.some((item) => item[0] === validatorAddress); | ||
|
||
const { apy, isApyApproxZero } = rollingAverageApys?.[validatorAddress] ?? { | ||
apy: null, | ||
}; | ||
|
||
const commission = validatorSummary ? Number(validatorSummary.commissionRate) / 100 : 0; | ||
|
||
return { | ||
system, | ||
isPendingValidators, | ||
errorValidators, | ||
|
||
currentEpoch, | ||
validatorSummary, | ||
name: validatorSummary?.name || '', | ||
stakingPoolActivationEpoch, | ||
commission, | ||
newValidator, | ||
isAtRisk, | ||
apy, | ||
isApyApproxZero, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 0 additions & 74 deletions
74
apps/wallet-dashboard/components/Dialogs/StakeDetails/StakeDetailsDialog.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
apps/wallet-dashboard/components/Dialogs/StakeDetails/index.ts
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
apps/wallet-dashboard/components/Dialogs/StakeDetails/views/StakeDetailsView.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
apps/wallet-dashboard/components/Dialogs/StakeDetails/views/index.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.