Skip to content

Commit

Permalink
Merge branch 'develop' into devx/fix-navbar-items-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjain23 authored Dec 20, 2024
2 parents 31ae952 + 78f337f commit 871d53a
Show file tree
Hide file tree
Showing 30 changed files with 1,576 additions and 1,293 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/_move_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,24 @@ jobs:
tool: nextest
- name: Run move tests
run: |
cargo nextest run -p iota-framework-tests -- unit_tests::
cargo nextest run -E
'package(iota-framework-tests)
or (package(iota-core) and test(quorum_driver::))
or package(iota-benchmark)
or test(move_tests::)'
move-simtest:
timeout-minutes: 10
runs-on: [self-hosted]
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- uses: taiki-e/install-action@375e0c7f08a66b8c2ba7e7eef31a6f91043a81b0 # v2.44.38
with:
tool: nextest
- name: Run move tests
run: |
scripts/simtest/cargo-simtest simtest --profile ci -E
'package(iota-framework-tests)
or (package(iota-core) and test(quorum_driver::))
or package(iota-benchmark)
or test(move_tests::)'
8 changes: 8 additions & 0 deletions apps/wallet-dashboard/app/(protected)/migrations/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ import { STARDUST_BASIC_OUTPUT_TYPE, STARDUST_NFT_OUTPUT_TYPE, useFormatCoin } f
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { StardustOutputMigrationStatus } from '@/lib/enums';
import { MigrationObjectsPanel, MigrationDialog } from '@/components';
import { useRouter } from 'next/navigation';

function MigrationDashboardPage(): JSX.Element {
const account = useCurrentAccount();
const address = account?.address || '';
const queryClient = useQueryClient();
const iotaClient = useIotaClient();
const router = useRouter();
const [isMigrationDialogOpen, setIsMigrationDialogOpen] = useState(false);
const [selectedStardustObjectsCategory, setSelectedStardustObjectsCategory] = useState<
StardustOutputMigrationStatus | undefined
Expand Down Expand Up @@ -139,6 +141,11 @@ function MigrationDashboardPage(): JSX.Element {
setSelectedStardustObjectsCategory(undefined);
}

function handleMigrationDialogClose() {
setIsMigrationDialogOpen(false);
router.push('/');
}

return (
<div className="flex h-full w-full flex-wrap items-center justify-center space-y-4">
<div
Expand All @@ -159,6 +166,7 @@ function MigrationDashboardPage(): JSX.Element {
selectedStardustObjectsCategory ===
StardustOutputMigrationStatus.TimeLocked
}
handleClose={handleMigrationDialogClose}
/>
)}
<Panel>
Expand Down
176 changes: 0 additions & 176 deletions apps/wallet-dashboard/components/Dialogs/MigrationDialog.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/wallet-dashboard/components/Dialogs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export * from './Staking';
export * from './unstake';
export * from './vesting';
export * from './settings';
export * from './MigrationDialog';
export * from './migration';
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import React, { useState } from 'react';
import { useCurrentAccount, useSignAndExecuteTransaction } from '@iota/dapp-kit';
import { IotaObjectData } from '@iota/iota-sdk/client';
import { useMigrationTransaction } from '@/hooks/useMigrationTransaction';
import { Dialog } from '@iota/apps-ui-kit';
import toast from 'react-hot-toast';
import { TransactionDialogView } from '../TransactionDialog';
import { MigrationDialogView } from './enums';
import { ConfirmMigrationView } from './views';

interface MigrationDialogProps {
handleClose: () => void;
basicOutputObjects: IotaObjectData[] | undefined;
nftOutputObjects: IotaObjectData[] | undefined;
onSuccess: (digest: string) => void;
setOpen: (bool: boolean) => void;
open: boolean;
isTimelocked: boolean;
}

export function MigrationDialog({
handleClose,
basicOutputObjects = [],
nftOutputObjects = [],
onSuccess,
open,
setOpen,
isTimelocked,
}: MigrationDialogProps): JSX.Element {
const account = useCurrentAccount();
const [txDigest, setTxDigest] = useState<string>('');
const [view, setView] = useState<MigrationDialogView>(MigrationDialogView.Confirmation);

const {
data: migrateData,
isPending: isMigrationPending,
isError: isMigrationError,
} = useMigrationTransaction(account?.address || '', basicOutputObjects, nftOutputObjects);

const { mutateAsync: signAndExecuteTransaction, isPending: isSendingTransaction } =
useSignAndExecuteTransaction();

async function handleMigrate(): Promise<void> {
if (!migrateData) return;
signAndExecuteTransaction(
{
transaction: migrateData.transaction,
},
{
onSuccess: (tx) => {
onSuccess(tx.digest);
setTxDigest(tx.digest);
setView(MigrationDialogView.TransactionDetails);
},
},
)
.then(() => {
toast.success('Migration transaction has been sent');
})
.catch(() => {
toast.error('Migration transaction was not sent');
});
}

return (
<Dialog open={open} onOpenChange={setOpen}>
{view === MigrationDialogView.Confirmation && (
<ConfirmMigrationView
basicOutputObjects={basicOutputObjects}
nftOutputObjects={nftOutputObjects}
onSuccess={handleMigrate}
setOpen={setOpen}
isTimelocked={isTimelocked}
migrateData={migrateData}
isMigrationPending={isMigrationPending}
isMigrationError={isMigrationError}
isSendingTransaction={isSendingTransaction}
/>
)}
{view === MigrationDialogView.TransactionDetails && (
<TransactionDialogView txDigest={txDigest} onClose={handleClose} />
)}
</Dialog>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export * from './view.enums';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export enum MigrationDialogView {
Confirmation = 'Confirmation',
TransactionDetails = 'TransactionDetails',
}
6 changes: 6 additions & 0 deletions apps/wallet-dashboard/components/Dialogs/migration/index.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 * from './MigrationDialog';

export * from './views';
Loading

0 comments on commit 871d53a

Please sign in to comment.