From 4ce80fcdb968a58caffb81c7611734e3c7a8d420 Mon Sep 17 00:00:00 2001 From: evavirseda Date: Tue, 14 Jan 2025 13:45:35 +0100 Subject: [PATCH 1/3] feat(wallet-dashboard): do not allow timelocked staking if there are not enough funds (#4645) * feat: fix coinditions * fix lint * fix: add isSupplyIncreaseVestingScheduleEmpty to hook * fix condition --- .../app/(protected)/vesting/page.tsx | 8 +++++--- apps/wallet-dashboard/components/Banner.tsx | 11 ++++++++++- .../components/SupplyIncreaseVestingOverview.tsx | 7 ++----- .../hooks/useGetSupplyIncreaseVestingObjects.ts | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/apps/wallet-dashboard/app/(protected)/vesting/page.tsx b/apps/wallet-dashboard/app/(protected)/vesting/page.tsx index d3c147c319f..d3acfb188e8 100644 --- a/apps/wallet-dashboard/app/(protected)/vesting/page.tsx +++ b/apps/wallet-dashboard/app/(protected)/vesting/page.tsx @@ -83,11 +83,11 @@ export default function VestingDashboardPage(): JSX.Element { nextPayout, supplyIncreaseVestingPortfolio, supplyIncreaseVestingSchedule, - supplyIncreaseVestingMapped, supplyIncreaseVestingStakedMapped, isTimelockedStakedObjectsLoading, unlockAllSupplyIncreaseVesting, refreshStakeList, + isSupplyIncreaseVestingScheduleEmpty, } = useGetSupplyIncreaseVestingObjects(address); const timelockedStakedObjectsGrouped: TimelockedStakedObjectsGrouped[] = @@ -297,18 +297,20 @@ export default function VestingDashboardPage(): JSX.Element { - {supplyIncreaseVestingMapped.length === 0 ? ( + {isSupplyIncreaseVestingScheduleEmpty ? ( handleNewStake()} buttonText="Stake" + disabled={supplyIncreaseVestingSchedule.availableStaking === 0n} /> ) : null} - {supplyIncreaseVestingMapped.length !== 0 ? ( + {!isSupplyIncreaseVestingScheduleEmpty && + supplyIncreaseVestingSchedule.totalStaked !== 0n ? (
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 "> @@ -29,6 +37,7 @@ export function Banner({ videoSrc, title, subtitle, onButtonClick, buttonText }: size={ButtonSize.Small} type={ButtonType.Outlined} text={buttonText} + disabled={disabled} /> </div> </div> diff --git a/apps/wallet-dashboard/components/SupplyIncreaseVestingOverview.tsx b/apps/wallet-dashboard/components/SupplyIncreaseVestingOverview.tsx index 5d79759ad35..647c1aa5d01 100644 --- a/apps/wallet-dashboard/components/SupplyIncreaseVestingOverview.tsx +++ b/apps/wallet-dashboard/components/SupplyIncreaseVestingOverview.tsx @@ -29,7 +29,7 @@ export function SupplyIncreaseVestingOverview() { const { nextPayout, supplyIncreaseVestingSchedule, - supplyIncreaseVestingMapped, + isSupplyIncreaseVestingScheduleEmpty, supplyIncreaseVestingStakedMapped, } = useGetSupplyIncreaseVestingObjects(address); @@ -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({ @@ -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" /> diff --git a/apps/wallet-dashboard/hooks/useGetSupplyIncreaseVestingObjects.ts b/apps/wallet-dashboard/hooks/useGetSupplyIncreaseVestingObjects.ts index 58d19d63641..e086333e4ce 100644 --- a/apps/wallet-dashboard/hooks/useGetSupplyIncreaseVestingObjects.ts +++ b/apps/wallet-dashboard/hooks/useGetSupplyIncreaseVestingObjects.ts @@ -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; @@ -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( @@ -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(); @@ -108,5 +118,6 @@ export function useGetSupplyIncreaseVestingObjects(address: string): { isTimelockedStakedObjectsLoading, unlockAllSupplyIncreaseVesting, refreshStakeList, + isSupplyIncreaseVestingScheduleEmpty, }; } From 6b954e6610ce3f056010ce0407c15bf7a32891cd Mon Sep 17 00:00:00 2001 From: evavirseda <evirseda@boxfish.studio> Date: Tue, 14 Jan 2025 13:54:23 +0100 Subject: [PATCH 2/3] feat: add resolvedObjetcs (#4744) --- .../components/dialogs/migration/views/ConfirmMigrationView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/wallet-dashboard/components/dialogs/migration/views/ConfirmMigrationView.tsx b/apps/wallet-dashboard/components/dialogs/migration/views/ConfirmMigrationView.tsx index bd9071e3a6c..230f22e56cd 100644 --- a/apps/wallet-dashboard/components/dialogs/migration/views/ConfirmMigrationView.tsx +++ b/apps/wallet-dashboard/components/dialogs/migration/views/ConfirmMigrationView.tsx @@ -70,6 +70,7 @@ export function ConfirmMigrationView({ basicOutputs: basicOutputObjects, nftOutputs: nftOutputObjects, address: account?.address || '', + resolvedObjects: resolvedObjects, }); const [timelockedIotaTokens, symbol] = useFormatCoin(totalIotaAmount, IOTA_TYPE_ARG); From 674b1414c5ccdc22c32698bddd482d7ec65775f1 Mon Sep 17 00:00:00 2001 From: Roman Overko <63564739+roman1e2f5p8s@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:15:19 +0100 Subject: [PATCH 3/3] chore(iota-indexer): fix typos in IndexerMetrics (#4763) --- crates/iota-indexer/src/metrics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/iota-indexer/src/metrics.rs b/crates/iota-indexer/src/metrics.rs index 0e01cb3c317..4f220c1bad3 100644 --- a/crates/iota-indexer/src/metrics.rs +++ b/crates/iota-indexer/src/metrics.rs @@ -337,7 +337,7 @@ impl IndexerMetrics { ).unwrap(), fullnode_checkpoint_data_download_latency: register_histogram_with_registry!( "fullnode_checkpoint_data_download_latency", - "Time spent in downloading checkpoint and transation for a new checkpoint from the Full Node", + "Time spent in downloading checkpoint and transaction for a new checkpoint from the Full Node", DATA_INGESTION_LATENCY_SEC_BUCKETS.to_vec(), registry, ) @@ -458,7 +458,7 @@ impl IndexerMetrics { ) .unwrap(), checkpoint_db_commit_latency_transactions_chunks_transformation: register_histogram_with_registry!( - "checkpoint_db_commit_latency_transactions_transaformation", + "checkpoint_db_commit_latency_transactions_transformation", "Time spent in transactions chunks transformation prior to commit", DATA_INGESTION_LATENCY_SEC_BUCKETS.to_vec(), registry,