-
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(wallet-dashboard): add staking confirmation screen
- Loading branch information
Showing
7 changed files
with
159 additions
and
54 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
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
// 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 { ValidatorApyData } 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; | ||
validatorApy: ValidatorApyData; | ||
} | ||
|
||
export function SuccessScreenView({ | ||
validatorAddress, | ||
gasBudget, | ||
onConfirm, | ||
amount, | ||
symbol, | ||
validatorApy: { apy, isApyApproxZero }, | ||
}: SuccessScreenViewProps): React.JSX.Element { | ||
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} | ||
isApyApproxZero={isApyApproxZero} | ||
/> | ||
</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
55 changes: 55 additions & 0 deletions
55
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,55 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Divider, KeyValueInfo, Panel } from '@iota/apps-ui-kit'; | ||
import { useFormatCoin, ValidatorApyData } from '@iota/core'; | ||
import { useIotaClientQuery } from '@iota/dapp-kit'; | ||
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; | ||
import { useStakeTxnInfo } from '../hooks'; | ||
|
||
interface StakingTransactionDetailsProps extends ValidatorApyData { | ||
gasBudget: string | number | null | undefined; | ||
} | ||
|
||
export function StakingTransactionDetails({ | ||
gasBudget, | ||
apy, | ||
isApyApproxZero, | ||
}: StakingTransactionDetailsProps): React.JSX.Element { | ||
const [gas, gasSymbol] = useFormatCoin(gasBudget, IOTA_TYPE_ARG); | ||
const { data: system } = useIotaClientQuery('getLatestIotaSystemState'); | ||
|
||
const { stakedRewardsStartEpoch, timeBeforeStakeRewardsRedeemableAgoDisplay } = useStakeTxnInfo( | ||
system?.epoch, | ||
); | ||
|
||
const apyDisplay = `${isApyApproxZero ? '~' : ''}${apy}%`; | ||
|
||
return ( | ||
<Panel hasBorder> | ||
<div className="flex flex-col gap-y-sm p-md"> | ||
{apy !== null && apy !== undefined ? ( | ||
<KeyValueInfo keyText="APY" value={apyDisplay} 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