-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add staking confirmation screen
- Loading branch information
Showing
6 changed files
with
155 additions
and
55 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
65 changes: 65 additions & 0 deletions
65
apps/wallet-dashboard/components/Dialogs/Staking/views/ConfirmAndExit.tsx
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,65 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { | ||
Button, | ||
ButtonType, | ||
Card, | ||
CardBody, | ||
CardImage, | ||
CardType, | ||
ImageShape, | ||
ImageType, | ||
} from '@iota/apps-ui-kit'; | ||
import { useValidatorInfo } from '@iota/core'; | ||
import { StakingTransactionDetails } from './StakingTransactionDetails'; | ||
import { Validator } from './Validator'; | ||
import { IotaLogoMark } from '@iota/ui-icons'; | ||
|
||
interface SuccessScreenViewProps { | ||
validatorAddress: string; | ||
gasBudget: string | number | null | undefined; | ||
onConfirm: () => void; | ||
amount: string; | ||
symbol: string | undefined; | ||
} | ||
|
||
export function SuccessScreenView({ | ||
validatorAddress, | ||
gasBudget, | ||
onConfirm, | ||
amount, | ||
symbol, | ||
}: SuccessScreenViewProps): React.JSX.Element { | ||
const { apy } = useValidatorInfo({ | ||
validatorAddress, | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-1 flex-col"> | ||
<div className="flex w-full flex-1 flex-col justify-between"> | ||
<div className="flex flex-col gap-y-md"> | ||
<Validator address={validatorAddress} isSelected showAction={false} /> | ||
|
||
<Card type={CardType.Outlined}> | ||
<CardImage type={ImageType.BgSolid} shape={ImageShape.Rounded}> | ||
<IotaLogoMark className="h-5 w-5 text-neutral-10" /> | ||
</CardImage> | ||
<CardBody title={`${amount} ${symbol}`} subtitle="Stake" /> | ||
</Card> | ||
|
||
<StakingTransactionDetails gasBudget={gasBudget} apy={apy} /> | ||
</div> | ||
</div> | ||
|
||
<div className="flex w-full"> | ||
<Button | ||
type={ButtonType.Primary} | ||
fullWidth | ||
onClick={onConfirm} | ||
text="Confirm & Exit" | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
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
53 changes: 53 additions & 0 deletions
53
apps/wallet-dashboard/components/Dialogs/Staking/views/StakingTransactionDetails.tsx
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,53 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Divider, KeyValueInfo, Panel } from '@iota/apps-ui-kit'; | ||
import { useFormatCoin } from '@iota/core'; | ||
import { useIotaClientQuery } from '@iota/dapp-kit'; | ||
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; | ||
import { useStakeTxnInfo } from '../hooks'; | ||
|
||
interface StakingTransactionDetailsProps { | ||
gasBudget: string | number | null | undefined; | ||
apy?: number | null; | ||
} | ||
|
||
export function StakingTransactionDetails({ | ||
gasBudget, | ||
apy, | ||
}: StakingTransactionDetailsProps): React.JSX.Element { | ||
const [gas, gasSymbol] = useFormatCoin(gasBudget, IOTA_TYPE_ARG); | ||
const { data: system } = useIotaClientQuery('getLatestIotaSystemState'); | ||
|
||
const { stakedRewardsStartEpoch, timeBeforeStakeRewardsRedeemableAgoDisplay } = useStakeTxnInfo( | ||
system?.epoch, | ||
); | ||
|
||
return ( | ||
<Panel hasBorder> | ||
<div className="flex flex-col gap-y-sm p-md"> | ||
{apy !== null && apy !== undefined ? ( | ||
<KeyValueInfo keyText="APY" value={`${apy}%`} fullwidth /> | ||
) : null} | ||
|
||
<KeyValueInfo | ||
keyText="Staking Rewards Start" | ||
value={stakedRewardsStartEpoch} | ||
fullwidth | ||
/> | ||
<KeyValueInfo | ||
keyText="Redeem Rewards" | ||
value={timeBeforeStakeRewardsRedeemableAgoDisplay} | ||
fullwidth | ||
/> | ||
<Divider /> | ||
<KeyValueInfo | ||
keyText="Gas fee" | ||
value={gas || '--'} | ||
supportingLabel={gasSymbol} | ||
fullwidth | ||
/> | ||
</div> | ||
</Panel> | ||
); | ||
} |
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