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

feat(wallet-dashboard): add unstake timelocked objects flow #4300

Merged
merged 39 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fc05cae
feat(dashboard): add unstake timelocked objects view
VmMad Nov 28, 2024
3ed6d5e
refactor: improve function
VmMad Nov 28, 2024
0fc7a62
feat: add more unstaking information and rename constant
VmMad Dec 4, 2024
93ade20
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 4, 2024
068a798
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 4, 2024
c70f4f1
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 5, 2024
d0234e7
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 5, 2024
da6de48
refactor: imports
VmMad Dec 5, 2024
d4ff8b4
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 5, 2024
ec530eb
fix: imports
VmMad Dec 5, 2024
7a31083
fix: remove duplication collapsible
VmMad Dec 9, 2024
3e3f85a
refactor: include both single stake and grouped in a unstake hook
VmMad Dec 9, 2024
f4ce8e4
refactor: unify usntake panel
VmMad Dec 10, 2024
c3392cc
fix: go back correctly to previous screen in staking
VmMad Dec 10, 2024
377e1cc
refactor: cleanup
VmMad Dec 10, 2024
0de0218
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 10, 2024
597a179
refactor: remove popups
VmMad Dec 10, 2024
34b042c
refactor: remove popups
VmMad Dec 10, 2024
0229429
revert "refactor: remove popups"
VmMad Dec 10, 2024
b68af14
refactor: remove only unnecessary popups
VmMad Dec 10, 2024
0a12460
refactor: divide hooks and move deeper inside components
VmMad Dec 10, 2024
0cf1080
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
VmMad Dec 12, 2024
3a7586e
fix: resolve re rendering issue
VmMad Dec 12, 2024
eb8cd1e
feat: remove redundant code
VmMad Dec 12, 2024
798a8ff
fix: update conditionally showing the stake dialog
VmMad Dec 12, 2024
21104d3
fix(tooling-dashboard): improve stake wizard (#4454)
brancoder Dec 13, 2024
c8c2047
refactor: imports / exports
VmMad Dec 13, 2024
338400a
feat: add wait for transaction and refresh
VmMad Dec 13, 2024
c19da61
feat: improve dialogs
VmMad Dec 16, 2024
db718f5
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
cpl121 Dec 16, 2024
8dba2e0
Merge branch 'develop' into tooling-dashboard/add-timelocked-unstake-…
cpl121 Dec 17, 2024
c230547
feat(dashboard): minor fixes
cpl121 Dec 17, 2024
2f1d5de
fix: query key for timelocked staking
brancoder Dec 17, 2024
cffe6e5
fix: revert constants changes
brancoder Dec 17, 2024
d2cc8d1
fix: resolve conflicts
brancoder Dec 17, 2024
411d0c9
fix: disable stake button if no available amount for staking
brancoder Dec 17, 2024
7b3e80b
fix: query key for timelocked staking transaction
brancoder Dec 17, 2024
29a46ac
fix: bigint serialization
brancoder Dec 17, 2024
b336b19
fix: remove or check in the useNewStakeTimelockedTransaction
brancoder Dec 17, 2024
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 @@ -57,6 +57,10 @@ interface KeyValueProps {
* Reverse the KeyValue (optional).
*/
isReverse?: boolean;
/**
* Text shown on value hover.
*/
valueHoverTitle?: string;
}

export function KeyValueInfo({
Expand All @@ -72,6 +76,7 @@ export function KeyValueInfo({
onCopyError,
fullwidth,
isReverse = false,
valueHoverTitle,
}: KeyValueProps): React.JSX.Element {
const flexDirectionClass = isReverse ? 'flex-row-reverse' : 'flex-row';
async function handleCopyClick(event: React.MouseEvent<HTMLButtonElement>) {
Expand Down Expand Up @@ -119,6 +124,7 @@ export function KeyValueInfo({
})}
>
<span
title={valueHoverTitle}
className={cx(
'text-neutral-10 dark:text-neutral-92',
size === ValueSize.Medium ? 'text-body-lg' : 'text-body-md',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ export interface LoadingIndicatorProps {
* The text to display next to the loading indicator.
*/
text?: string;
/**
* The 'data-testid' attribute value (used in e2e tests)
*/
testId?: string;
}

export function LoadingIndicator({
color = 'text-primary-30 dark:text-primary-80',
size = 'w-5 h-5',
text,
testId,
}: LoadingIndicatorProps): React.JSX.Element {
return (
<div className="flex items-center justify-center gap-xs">
<Loader className={cx('animate-spin', color, size)} />
<Loader className={cx('animate-spin', color, size)} data-testid={testId} />
{text && <span className={cx('text-body-sm', color)}>{text}</span>}
</div>
);
Expand Down
80 changes: 67 additions & 13 deletions apps/wallet-dashboard/app/(protected)/staking/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

'use client';

import { StartStaking } from '@/components/staking-overview/StartStaking';
import {
Button,
ButtonSize,
Expand All @@ -16,7 +15,15 @@ import {
Title,
TitleSize,
} from '@iota/apps-ui-kit';
import { StakeDialog, StakeDialogView } from '@/components';
import {
StakeDialog,
StakeDialogView,
UnstakeDialog,
useUnstakeDialog,
UnstakeDialogView,
useStakeDialog,
StartStaking,
} from '@/components';
import {
ExtendedDelegatedStake,
formatDelegatedStake,
Expand All @@ -32,8 +39,8 @@ import { useCurrentAccount, useIotaClient, useIotaClientQuery } from '@iota/dapp
import { IotaSystemStateSummary } from '@iota/iota-sdk/client';
import { Info } from '@iota/ui-icons';
import { useMemo } from 'react';
import { useStakeDialog } from '@/components/Dialogs/Staking/hooks/useStakeDialog';
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { IotaSignAndExecuteTransactionOutput } from '@iota/wallet-standard';

function StakingDashboardPage(): React.JSX.Element {
const account = useCurrentAccount();
Expand All @@ -52,6 +59,14 @@ function StakingDashboardPage(): React.JSX.Element {
handleCloseStakeDialog,
handleNewStake,
} = useStakeDialog();
const {
isOpen: isUnstakeDialogOpen,
openUnstakeDialog,
defaultDialogProps,
handleClose: handleCloseUnstakeDialog,
setView: setUnstakeDialogView,
setTxDigest,
} = useUnstakeDialog();

const { data: delegatedStakeData, refetch: refetchDelegatedStakes } = useGetDelegatedStake({
address: account?.address || '',
Expand Down Expand Up @@ -100,6 +115,34 @@ function StakingDashboardPage(): React.JSX.Element {
.then(() => refetchDelegatedStakes());
}

function handleUnstakeClick() {
setStakeDialogView(undefined);
openUnstakeDialog();
}

function handleUnstakeDialogBack() {
setStakeDialogView(StakeDialogView.Details);
handleCloseUnstakeDialog();
}

function handleOnUnstakeBack(view: UnstakeDialogView): (() => void) | undefined {
if (view === UnstakeDialogView.Unstake) {
return handleUnstakeDialogBack;
}
}

function handleOnUnstakeSuccess(tx: IotaSignAndExecuteTransactionOutput): void {
setUnstakeDialogView(UnstakeDialogView.TransactionDetails);
iotaClient
.waitForTransaction({
digest: tx.digest,
})
.then((tx) => {
refetchDelegatedStakes();
setTxDigest(tx.digest);
});
}

return (
<div className="flex justify-center">
<div className="w-3/4">
Expand Down Expand Up @@ -171,16 +214,27 @@ function StakingDashboardPage(): React.JSX.Element {
</div>
</div>
</div>
<StakeDialog
stakedDetails={selectedStake}
onSuccess={handleOnStakeSuccess}
isOpen={isDialogStakeOpen}
handleClose={handleCloseStakeDialog}
view={stakeDialogView}
setView={setStakeDialogView}
selectedValidator={selectedValidator}
setSelectedValidator={setSelectedValidator}
/>
{isDialogStakeOpen && (
<StakeDialog
stakedDetails={selectedStake}
onSuccess={handleOnStakeSuccess}
handleClose={handleCloseStakeDialog}
view={stakeDialogView}
setView={setStakeDialogView}
selectedValidator={selectedValidator}
setSelectedValidator={setSelectedValidator}
onUnstakeClick={handleUnstakeClick}
/>
)}

{isUnstakeDialogOpen && selectedStake && (
<UnstakeDialog
extendedStake={selectedStake}
onBack={handleOnUnstakeBack}
onSuccess={handleOnUnstakeSuccess}
{...defaultDialogProps}
/>
)}
</Panel>
) : (
<div className="flex h-[270px] p-lg">
Expand Down
Loading
Loading