Skip to content

Commit

Permalink
Merge branches 'tooling-dashboard/improve-tx-history-and-details' and…
Browse files Browse the repository at this point in the history
… 'develop' of github.com:iotaledger/iota into tooling-dashboard/improve-tx-history-and-details
  • Loading branch information
cpl121 committed Jan 15, 2025
2 parents 64e731f + 3baf0e2 commit 7d009b0
Show file tree
Hide file tree
Showing 11 changed files with 446 additions and 32 deletions.
8 changes: 5 additions & 3 deletions apps/wallet-dashboard/app/(protected)/vesting/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default function VestingDashboardPage(): JSX.Element {
nextPayout,
supplyIncreaseVestingPortfolio,
supplyIncreaseVestingSchedule,
supplyIncreaseVestingMapped,
supplyIncreaseVestingStakedMapped,
isTimelockedStakedObjectsLoading,
unlockAllSupplyIncreaseVesting,
refreshStakeList,
isSupplyIncreaseVestingScheduleEmpty,
} = useGetSupplyIncreaseVestingObjects(address);

const timelockedStakedObjectsGrouped: TimelockedStakedObjectsGrouped[] =
Expand Down Expand Up @@ -297,18 +297,20 @@ export default function VestingDashboardPage(): JSX.Element {
</div>
</Panel>

{supplyIncreaseVestingMapped.length === 0 ? (
{isSupplyIncreaseVestingScheduleEmpty ? (
<Banner
videoSrc={videoSrc}
title="Stake Vested Tokens"
subtitle="Earn Rewards"
onButtonClick={() => handleNewStake()}
buttonText="Stake"
disabled={supplyIncreaseVestingSchedule.availableStaking === 0n}
/>
) : null}
</div>

{supplyIncreaseVestingMapped.length !== 0 ? (
{!isSupplyIncreaseVestingScheduleEmpty &&
supplyIncreaseVestingSchedule.totalStaked !== 0n ? (
<div className="flex w-full md:w-1/2">
<Panel>
<Title
Expand Down
11 changes: 10 additions & 1 deletion apps/wallet-dashboard/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ interface BannerProps {
subtitle?: string;
onButtonClick: () => void;
buttonText: string;
disabled?: boolean;
}
export function Banner({ videoSrc, title, subtitle, onButtonClick, buttonText }: BannerProps) {
export function Banner({
videoSrc,
title,
subtitle,
onButtonClick,
buttonText,
disabled,
}: BannerProps) {
return (
<Panel bgColor="bg-secondary-90 dark:bg-secondary-10">
<div className="flex h-full w-full justify-between ">
Expand All @@ -29,6 +37,7 @@ export function Banner({ videoSrc, title, subtitle, onButtonClick, buttonText }:
size={ButtonSize.Small}
type={ButtonType.Outlined}
text={buttonText}
disabled={disabled}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function SupplyIncreaseVestingOverview() {
const {
nextPayout,
supplyIncreaseVestingSchedule,
supplyIncreaseVestingMapped,
isSupplyIncreaseVestingScheduleEmpty,
supplyIncreaseVestingStakedMapped,
} = useGetSupplyIncreaseVestingObjects(address);

Expand Down Expand Up @@ -57,9 +57,6 @@ export function SupplyIncreaseVestingOverview() {
IOTA_TYPE_ARG,
);

const showSupplyIncreaseVestingOverview =
supplyIncreaseVestingMapped.length > 0 || supplyIncreaseVestingStakedMapped.length > 0;

function handleOnSuccess(digest: string): void {
iotaClient
.waitForTransaction({
Expand All @@ -81,7 +78,7 @@ export function SupplyIncreaseVestingOverview() {
});
}

return showSupplyIncreaseVestingOverview ? (
return !isSupplyIncreaseVestingScheduleEmpty || supplyIncreaseVestingStakedMapped.length > 0 ? (
<div style={{ gridArea: 'vesting' }} className="with-vesting flex grow overflow-hidden">
<Panel>
<Title title="Vesting" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function ConfirmMigrationView({
basicOutputs: basicOutputObjects,
nftOutputs: nftOutputObjects,
address: account?.address || '',
resolvedObjects: resolvedObjects,
});

const [timelockedIotaTokens, symbol] = useFormatCoin(totalIotaAmount, IOTA_TYPE_ARG);
Expand Down
15 changes: 13 additions & 2 deletions apps/wallet-dashboard/hooks/useGetSupplyIncreaseVestingObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '@iota/core';
import { Transaction } from '@iota/iota-sdk/transactions';

export function useGetSupplyIncreaseVestingObjects(address: string): {
interface SupplyIncreaseVestingObject {
nextPayout: SupplyIncreaseVestingPayout | undefined;
lastPayout: SupplyIncreaseVestingPayout | undefined;
supplyIncreaseVestingSchedule: VestingOverview;
Expand All @@ -40,7 +40,10 @@ export function useGetSupplyIncreaseVestingObjects(address: string): {
}
| undefined;
refreshStakeList: () => void;
} {
isSupplyIncreaseVestingScheduleEmpty: boolean;
}

export function useGetSupplyIncreaseVestingObjects(address: string): SupplyIncreaseVestingObject {
const { data: currentEpochMs } = useGetCurrentEpochStartTimestamp();

const { data: timelockedObjects, refetch: refetchGetAllOwnedObjects } = useGetAllOwnedObjects(
Expand Down Expand Up @@ -93,6 +96,13 @@ export function useGetSupplyIncreaseVestingObjects(address: string): {
supplyIncreaseVestingUnlockedObjectIds,
);

const isSupplyIncreaseVestingScheduleEmpty =
!supplyIncreaseVestingSchedule.totalVested &&
!supplyIncreaseVestingSchedule.totalLocked &&
!supplyIncreaseVestingSchedule.availableClaiming &&
!supplyIncreaseVestingSchedule.totalStaked &&
!supplyIncreaseVestingSchedule.totalEarned;

function refreshStakeList() {
refetchTimelockedStakedObjects();
refetchGetAllOwnedObjects();
Expand All @@ -108,5 +118,6 @@ export function useGetSupplyIncreaseVestingObjects(address: string): {
isTimelockedStakedObjectsLoading,
unlockAllSupplyIncreaseVesting,
refreshStakeList,
isSupplyIncreaseVestingScheduleEmpty,
};
}
Loading

0 comments on commit 7d009b0

Please sign in to comment.