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(tooling-dashboard): fetch stardust basic and nft objects #3801

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions apps/apps-backend/src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export class FeaturesController {
[Feature.AccountFinder]: {
defaultValue: false,
},
[Feature.WalletDashboardMigration]: {
[Feature.StardustMigration]: {
defaultValue: false,
},
[Feature.WalletDashboardSupplyIncreaseVesting]: {
[Feature.SupplyIncreaseVesting]: {
defaultValue: false,
},
},
Expand Down
81 changes: 68 additions & 13 deletions apps/wallet-dashboard/app/(protected)/migrations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,79 @@
// SPDX-License-Identifier: Apache-2.0
'use client';

import { useFeature } from '@growthbook/growthbook-react';
import { Feature } from '@iota/core';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import { VirtualList } from '@/components';
import {
STARDUST_BASIC_OUTPUT_TYPE,
STARDUST_NFT_OUTPUT_TYPE,
} from '@/lib/constants/migration.constants';
import { useGetOwnedObjects } from '@iota/core';
import { useCurrentAccount, useIotaClientContext } from '@iota/dapp-kit';
import { getNetwork, IotaObjectData } from '@iota/iota-sdk/client';

function MigrationDashboardPage(): JSX.Element {
const router = useRouter();
const stardustMigrationEnabled = useFeature<boolean>(Feature.StardustMigration).value;
const account = useCurrentAccount();
const { network } = useIotaClientContext();
const { explorer } = getNetwork(network);

useEffect(() => {
if (!stardustMigrationEnabled) {
router.push('/');
}
}, [stardustMigrationEnabled, router]);
const {
data: basicOutputObjects,
fetchNextPage: fetchNextPageBasic,
hasNextPage: hasNextPageBasic,
isFetchingNextPage: isFetchingNextPageBasic,
} = useGetOwnedObjects(account?.address || '', {
StructType: STARDUST_BASIC_OUTPUT_TYPE,
});
const {
data: nftOutputObjects,
fetchNextPage: fetchNextPageNft,
hasNextPage: hasNextPageNft,
isFetchingNextPage: isFetchingNextPageNft,
} = useGetOwnedObjects(account?.address || '', {
StructType: STARDUST_NFT_OUTPUT_TYPE,
});

const basicOutputs =
basicOutputObjects?.pages
.flatMap((page) => page.data)
.filter((asset) => asset.data && asset.data.objectId)
.map((response) => response.data!) ?? [];

const nftOutputs =
nftOutputObjects?.pages
.flatMap((page) => page.data)
.filter((asset) => asset.data && asset.data.objectId)
.map((response) => response.data!) ?? [];

const virtualItem = (asset: IotaObjectData): JSX.Element => (
<a href={`${explorer}/object/${asset.objectId}`} target="_blank" rel="noreferrer">
{asset.objectId}
</a>
);

return (
<div className="flex items-center justify-center pt-12">
<h1>MIGRATIONS</h1>
<div className="flex h-full w-full flex-row items-center justify-center space-y-4">
<div className="flex w-1/2 flex-col">
<h1>Basic Outputs</h1>
<VirtualList
items={basicOutputs}
hasNextPage={hasNextPageBasic}
isFetchingNextPage={isFetchingNextPageBasic}
fetchNextPage={fetchNextPageBasic}
estimateSize={() => 30}
render={virtualItem}
/>
</div>
<div className="flex w-1/2 flex-col">
<h1>Nft Outputs</h1>
<VirtualList
items={nftOutputs}
hasNextPage={hasNextPageNft}
isFetchingNextPage={isFetchingNextPageNft}
fetchNextPage={fetchNextPageNft}
estimateSize={() => 30}
render={virtualItem}
/>
</div>
</div>
);
}
Expand Down
6 changes: 6 additions & 0 deletions apps/wallet-dashboard/lib/constants/migration.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
export const STARDUST_PACKAGE_ID =
'000000000000000000000000000000000000000000000000000000000000107a';
export const STARDUST_BASIC_OUTPUT_TYPE = `${STARDUST_PACKAGE_ID}::basic_output::BasicOutput<0x2::iota::IOTA>`;
cpl121 marked this conversation as resolved.
Show resolved Hide resolved
export const STARDUST_NFT_OUTPUT_TYPE = `${STARDUST_PACKAGE_ID}::nft_output::NftOutput<0x2::iota::IOTA>`;
Loading