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): hint user about migration in homepage #5041

Merged
merged 38 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9bd0183
feat(core): add StardustIndexerClient
panteleymonchuk Jan 22, 2025
8ca684e
feat(dashboard): add stardust objects from indexer.
panteleymonchuk Jan 22, 2025
e4e7c69
feat(core): enhance StardustIndexerClient with basic output mapping a…
panteleymonchuk Jan 22, 2025
e8439d7
Merge branch 'develop' into tooling-wallet/add-objects-from-indexer
cpl121 Jan 23, 2025
8884242
feat(dashboard): add NFT resolved outputs retrieval and mapping funct…
panteleymonchuk Jan 23, 2025
adedf67
Merge remote-tracking branch 'origin/develop' into tooling-wallet/add…
panteleymonchuk Jan 23, 2025
01975e8
refactor(core, dashboard): unify output types and enhance mapping fun…
panteleymonchuk Jan 23, 2025
6c9c84a
feat(wallet-dashboard, core): enhance Stardust output handling and ad…
panteleymonchuk Jan 24, 2025
88f9c02
Merge remote-tracking branch 'origin/develop' into tooling-wallet/add…
panteleymonchuk Jan 24, 2025
47bebe0
Merge branch 'develop' into tooling-wallet/add-objects-from-indexer
panteleymonchuk Jan 27, 2025
f176c64
fix(core, dashboard): pr fixes
panteleymonchuk Jan 27, 2025
d9f9de7
feat: add migration popup
evavirseda Jan 27, 2025
940d709
Merge branch 'tooling-wallet/add-objects-from-indexer' into tooling-w…
evavirseda Jan 27, 2025
3e002b4
feat(sdk): add metadata configuration for stardustIndexer in .env.def…
panteleymonchuk Jan 28, 2025
cf895b3
Merge branch 'develop' into tooling-wallet/add-objects-from-indexer
panteleymonchuk Jan 28, 2025
026efe8
refactor(core): rename limit parameter to page_size in StardustIndexe…
panteleymonchuk Jan 28, 2025
4c523eb
refactor(core): update PageParams interface and adjust pagination par…
panteleymonchuk Jan 28, 2025
926413d
Merge remote-tracking branch 'origin/develop' into tooling-wallet/add…
panteleymonchuk Jan 28, 2025
b4c3ede
refactor(core): update return_amount
panteleymonchuk Jan 28, 2025
303563e
refactor(core): update StardustIndexerClient methods and rename hook …
panteleymonchuk Jan 28, 2025
9bdab66
refactor(dashboard): remove unused variables in useGetAllStardustShar…
panteleymonchuk Jan 28, 2025
234c459
fix: add missing 0x to stardust package id
begonaalvarezd Jan 28, 2025
3e3cd6a
Merge branch 'tooling-wallet/add-objects-from-indexer' into tooling-w…
begonaalvarezd Jan 28, 2025
3d50207
refactor(core, dashboard): update Stardust package ID format, improve…
panteleymonchuk Jan 28, 2025
c296a87
Merge branch 'tooling-wallet/add-objects-from-indexer' into tooling-w…
evavirseda Jan 29, 2025
6f3190c
feat: rename constants
evavirseda Jan 29, 2025
642600d
Merge remote-tracking branch 'origin/develop' into tooling-wallet/add…
panteleymonchuk Jan 29, 2025
f02d7cb
feat: add useGetStardustSharedObjects hook and move to core
evavirseda Jan 29, 2025
0bb8780
Merge branch 'tooling-wallet/add-objects-from-indexer' into tooling-w…
evavirseda Jan 29, 2025
599eba6
Merge branch 'develop' into tooling-wallet/hint-user-migration-in-hom…
evavirseda Jan 29, 2025
5c3431e
Merge branch 'develop' into tooling-wallet/hint-user-migration-in-hom…
evavirseda Jan 29, 2025
b8d4427
refactor: split shared object hooks
begonaalvarezd Jan 30, 2025
764a121
refactor: simplify code
begonaalvarezd Jan 30, 2025
1dbdcb0
fix build
evavirseda Jan 30, 2025
f25cbe6
Merge branch 'develop' into tooling-wallet/hint-user-migration-in-hom…
evavirseda Jan 30, 2025
d232934
fix: react query crash
begonaalvarezd Jan 30, 2025
ea309ae
fix: dashboard crash
begonaalvarezd Jan 30, 2025
9ec2a63
chore: remove debris
begonaalvarezd Jan 30, 2025
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
2 changes: 1 addition & 1 deletion apps/core/src/api/StardustIndexerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface PageParams {
}

export class StardustIndexerClient {
private baseUrl: string;
public baseUrl: string;

constructor(baseUrl?: string) {
if (!baseUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
'use client';

import { useIotaClientContext } from '@iota/dapp-kit';
import { StardustIndexerClientContext, useStardustIndexerClient } from '@iota/core';
import {
StardustIndexerClientContext,
useStardustIndexerClient,
} from './StardustIndexerClientContext';

export const StardustIndexerClientProvider: React.FC<React.PropsWithChildren> = ({ children }) => {
const { network } = useIotaClientContext();
Expand Down
1 change: 1 addition & 0 deletions apps/core/src/contexts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
export * from './ThemeContext';
export * from './HiddenAssetsProvider';
export * from './StardustIndexerClientContext';
export * from './StardustIndexerClientProvider';
3 changes: 3 additions & 0 deletions apps/core/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export * from './useGetNFTs';
export * from './useRecognizedPackages';
export * from './useTransferAsset';
export * from './useFeatureEnabledByNetwork';
export * from './useGetAllStardustSharedObjects';
export * from './useGetStardustSharedBasicObjects';
export * from './useGetStardustSharedNftObjects';

export * from './stake';
export * from './ui';
65 changes: 65 additions & 0 deletions apps/core/src/hooks/useGetAllStardustSharedObjects.ts
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 { useQuery } from '@tanstack/react-query';
import { IotaObjectData } from '@iota/iota-sdk/client';
import { useGetStardustSharedBasicObjects } from './useGetStardustSharedBasicObjects';
import { useGetStardustSharedNftObjects } from './useGetStardustSharedNftObjects';

const LIMIT_PER_REQ = 50;

export function useGetAllStardustSharedObjects(address: string) {
const fetchPaginatedData = async () => {
let allBasicOutputs: IotaObjectData[] = [];
let allNftOutputs: IotaObjectData[] = [];

let basicOutputPage = 1;
do {
const { data: basicObjects } = await useGetStardustSharedBasicObjects(
address,
LIMIT_PER_REQ,
basicOutputPage,
);

if (!basicObjects || !basicObjects?.length) {
break;
}

allBasicOutputs = [
...allBasicOutputs,
...(basicObjects as unknown as IotaObjectData[]),
];

basicOutputPage = basicObjects.length < LIMIT_PER_REQ ? 0 : basicOutputPage + 1;
} while (basicOutputPage > 0);

let nftOutputPage = 1;
do {
const { data: nftObjects } = await useGetStardustSharedNftObjects(
address,
LIMIT_PER_REQ,
nftOutputPage,
);

if (!nftObjects || !nftObjects?.length) {
break;
}

allNftOutputs = [...allNftOutputs, ...(nftObjects as unknown as IotaObjectData[])];

nftOutputPage = nftObjects.length < LIMIT_PER_REQ ? 0 : nftOutputPage + 1;
} while (nftOutputPage > 0);

return {
basic: allBasicOutputs,
nfts: allNftOutputs,
};
};

return useQuery({
queryKey: ['stardust-all-shared-objects', address],
queryFn: fetchPaginatedData,
enabled: !!address,
staleTime: 1000 * 60 * 5,
placeholderData: { basic: [], nfts: [] },
});
}
36 changes: 36 additions & 0 deletions apps/core/src/hooks/useGetStardustSharedBasicObjects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { useQuery } from '@tanstack/react-query';
import { useStardustIndexerClientContext } from '../contexts';

export function useGetStardustSharedBasicObjects(
address: string,
pageSize?: number,
page?: number,
) {
const { stardustIndexerClient } = useStardustIndexerClientContext();

return useQuery({
queryKey: [
'stardust-shared-basic-objects',
address,
pageSize,
page,
stardustIndexerClient?.baseUrl,
],
queryFn: async () => {
if (!stardustIndexerClient?.baseUrl) return [];

const basicOutputs = await stardustIndexerClient.getBasicResolvedOutputs(address, {
page,
pageSize,
});

return basicOutputs || [];
},
enabled: !!address,
staleTime: 1000 * 60 * 5,
placeholderData: [],
});
}
32 changes: 32 additions & 0 deletions apps/core/src/hooks/useGetStardustSharedNftObjects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { useQuery } from '@tanstack/react-query';
import { useStardustIndexerClientContext } from '../contexts';

export function useGetStardustSharedNftObjects(address: string, pageSize?: number, page?: number) {
const { stardustIndexerClient } = useStardustIndexerClientContext();

return useQuery({
queryKey: [
'stardust-shared-nft-objects',
address,
pageSize,
page,
stardustIndexerClient?.baseUrl,
],
queryFn: async () => {
if (!stardustIndexerClient?.baseUrl) return [];

const nftOutputs = await stardustIndexerClient.getNftResolvedOutputs(address, {
page,
pageSize,
});

return nftOutputs || [];
},
enabled: !!address,
staleTime: 1000 * 60 * 5,
placeholderData: [],
});
}
77 changes: 0 additions & 77 deletions apps/wallet-dashboard/hooks/useGetAllStardustSharedObjects.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
STARDUST_NFT_OUTPUT_TYPE,
TimeUnit,
useGetAllOwnedObjects,
useGetAllStardustSharedObjects,
} from '@iota/core';
import { useGetAllStardustSharedObjects } from './useGetAllStardustSharedObjects';

export function useGetStardustMigratableObjects(address: string) {
const { data: currentEpochMs } = useGetCurrentEpochStartTimestamp();
Expand All @@ -23,8 +23,8 @@ export function useGetStardustMigratableObjects(address: string) {
StructType: STARDUST_NFT_OUTPUT_TYPE,
});

const sharedBasicOutputObjects = stardustSharedObjectsData!.basic;
const sharedNftOutputObjects = stardustSharedObjectsData!.nfts;
const sharedBasicOutputObjects = stardustSharedObjectsData?.basic ?? [];
const sharedNftOutputObjects = stardustSharedObjectsData?.nfts ?? [];

return useQuery({
queryKey: [
Expand Down
3 changes: 1 addition & 2 deletions apps/wallet-dashboard/providers/AppProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { getAllNetworks, getDefaultNetwork } from '@iota/iota-sdk/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { useState } from 'react';
import { KioskClientProvider, useLocalStorage } from '@iota/core';
import { KioskClientProvider, StardustIndexerClientProvider, useLocalStorage } from '@iota/core';
import { growthbook } from '@/lib/utils';
import { ThemeProvider } from '@iota/core';
import { StardustIndexerClientProvider } from './StardustIndexerClientProvider';
import { createIotaClient } from '@/lib/utils/defaultRpcClient';

growthbook.init();
Expand Down
46 changes: 46 additions & 0 deletions apps/wallet/src/ui/app/pages/home/tokens/MigrationDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { Button, Dialog, DialogContent, DialogBody, Header } from '@iota/apps-ui-kit';
import { Theme, useTheme } from '@iota/core';
import MigrationImage from '_assets/images/migration_dialog.png';
import MigrationDarkImage from '_assets/images/migration_dialog_darkmode.png';
import { WALLET_DASHBOARD_URL } from '_src/shared/constants';

interface MigrationDialogProps {
open: boolean;
setOpen: (isOpen: boolean) => void;
}

export function MigrationDialog({ open, setOpen }: MigrationDialogProps) {
const { theme } = useTheme();

const imgSrc = theme === Theme.Dark ? MigrationDarkImage : MigrationImage;

function navigateToDashboard() {
window.open(WALLET_DASHBOARD_URL, '_blank');
}
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent containerId="overlay-portal-container">
<Header title="Migration" onClose={() => setOpen(false)} titleCentered />
<DialogBody>
<div className="flex flex-col gap-lg text-center">
<img src={imgSrc} alt="Migration" />
<div className="flex flex-col items-center justify-center gap-y-sm pb-md">
<span className="text-headline-sm text-neutral-10 dark:text-neutral-92">
Fast and Easy Migration
</span>
<span className="max-w-56 text-body-md text-neutral-40 dark:text-neutral-60">
Migrate your tokens to the new network to enjoy the latest features.
</span>
</div>
</div>
</DialogBody>
<div className="flex w-full flex-row justify-center gap-2 px-md--rs pb-md--rs pt-sm--rs">
<Button onClick={navigateToDashboard} fullWidth text="Go to Dashboard" />
</div>
</DialogContent>
</Dialog>
);
}
Loading
Loading