-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into devx/fix-navbar-items-ui
- Loading branch information
Showing
30 changed files
with
1,576 additions
and
1,293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 0 additions & 176 deletions
176
apps/wallet-dashboard/components/Dialogs/MigrationDialog.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
apps/wallet-dashboard/components/Dialogs/migration/MigrationDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
4 changes: 4 additions & 0 deletions
4
apps/wallet-dashboard/components/Dialogs/migration/enums/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
7 changes: 7 additions & 0 deletions
7
apps/wallet-dashboard/components/Dialogs/migration/enums/view.enums.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
Oops, something went wrong.