From 21f80724fd2877021cd70723bf333e30436fa68b Mon Sep 17 00:00:00 2001 From: JCNoguera <88061365+VmMad@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:31:45 +0100 Subject: [PATCH] refactor(wallet,dashboard): move `TransactionReceipt` to core (#4280) * refactor(wallet,dashboard): move `TransactionReceipt` to core * fix: improve imports * fix: remove unused file * fix: cleanup * rever previous commit * fix: types * fix: update tests * fix: format * refactor: update interfaces to put required first * fix: expandable list * fix: update imported dialog layouts * fix: update missing import * fix: update imports * refactor: rename file * fix(wallet): add core components to tailwind.config.ts * chore: improve interface sorting * fix: celanup types and imports * fix: wait for transaciton and refetch stakes --------- Co-authored-by: Bran <52735957+brancoder@users.noreply.github.com> --- .../buttons/ViewTxnOnExplorerButton.tsx | 23 +++ apps/core/src/components/buttons/index.ts | 4 + .../src/components}/cards/BalanceChanges.tsx | 83 ++++++----- .../components/cards}/ObjectChangeDisplay.tsx | 23 +-- .../src/components}/cards/ObjectChanges.tsx | 63 +++++---- apps/core/src/components/cards/index.ts | 5 + .../components/collapsible/Collapsible.tsx | 5 +- .../src/components/gas}/GasFees.tsx | 18 ++- .../src/components/gas}/GasSummary.tsx | 18 ++- apps/core/src/components/gas/index.ts | 5 + apps/core/src/components/index.ts | 4 + .../src/components/lists}/ExpandableList.tsx | 8 +- apps/core/src/components/lists/index.ts | 4 + .../transaction/TransactionReceipt.tsx | 101 ++++++++++++++ .../transaction/amount/TransactionAmount.tsx | 49 +++++++ .../components/transaction/amount/index.ts | 4 + .../details/StakeTransactionDetails.tsx | 69 +++++++++ .../components/transaction/details/index.ts | 4 + apps/core/src/components/transaction/index.ts | 7 + .../info/StakeTransactionInfo.tsx} | 23 ++- .../info/UnstakeTransactionInfo.tsx} | 37 +++-- .../src/components/transaction/info/index.ts | 5 + .../summary/TransactionSummary.tsx | 49 +++++++ .../components/transaction/summary/index.ts | 4 + apps/core/src/hooks/index.ts | 1 - .../hooks/useExtendedTransactionSummary.ts | 40 ------ apps/core/src/hooks/useGetTransaction.ts | 23 +++ apps/core/src/hooks/useTransactionSummary.ts | 12 +- apps/core/src/index.ts | 2 + .../interfaces/balanceChange.interfaces.ts | 10 ++ apps/core/src/interfaces/index.ts | 5 + .../interfaces/validatorLogo.interfaces.ts | 9 ++ apps/core/src/types/balanceChange.ts | 7 + apps/core/src/types/gasSummary.ts | 18 +++ apps/core/src/types/index.ts | 8 ++ apps/core/src/types/objectChange.ts | 26 ++++ apps/core/src/types/renderComponent.ts | 10 ++ apps/core/src/types/transactionSummary.ts | 14 ++ .../transaction/getBalanceChangeSummary.ts | 13 +- .../src/utils/transaction/getGasSummary.ts | 19 +-- .../utils/transaction/getObjectChangeLabel.ts | 2 +- .../transaction/getObjectChangeSummary.ts | 18 +-- .../src/utils/transaction/groupByOwner.ts | 2 +- apps/core/src/utils/transaction/index.ts | 1 - apps/core/src/utils/transaction/types.ts | 24 ---- .../components/gas-breakdown/GasBreakdown.tsx | 9 +- .../app/(protected)/staking/page.tsx | 19 ++- .../Dialogs/Assets/views/DetailsView.tsx | 14 +- .../Dialogs/Assets/views/SendView.tsx | 14 +- .../Dialogs/Staking/StakeDialog.tsx | 39 +++--- .../components/Dialogs/Staking/enums/index.ts | 4 + .../Dialogs/Staking/enums/view.enums.ts | 11 ++ .../Dialogs/Staking/hooks/useStakeDialog.ts | 3 +- .../components/Dialogs/Staking/index.ts | 1 + .../Dialogs/Staking/views/DetailsView.tsx | 14 +- .../Dialogs/Staking/views/EnterAmountView.tsx | 14 +- .../views/EnterTimelockedAmountView.tsx | 14 +- .../Staking/views/SelectValidatorView.tsx | 14 +- .../Dialogs/Staking/views/UnstakeView.tsx | 14 +- .../Dialogs/Staking/views/Validator.tsx | 30 +++- .../components/Dialogs/TransactionDialog.tsx | 59 ++++++++ .../Layout.tsx => layout/DialogLayout.tsx} | 6 +- .../components/Dialogs/layout/index.ts | 4 + .../Popup/Popups/TransactionDetailsPopup.tsx | 75 ---------- .../components/Popup/Popups/index.ts | 1 - .../components/transactions/GasSummary.tsx | 40 ------ .../transactions/TransactionSummary.tsx | 39 ++++-- .../transactions/TransactionTile.tsx | 131 +++++++++++++----- .../balance-changes/BalanceChangeEntries.tsx | 30 ---- .../balance-changes/BalanceChangeEntry.tsx | 39 ------ .../balance-changes/BalanceChanges.tsx | 19 --- .../transactions/balance-changes/index.ts | 6 - .../components/transactions/index.ts | 6 +- .../object-changes/ObjectChangeEntry.tsx | 44 ------ .../object-changes/ObjectChanges.tsx | 23 --- .../object-changes/ObjectDetail.tsx | 102 -------------- .../transactions/object-changes/index.ts | 6 - .../ui/app/components/ExplorerLinkHelper.tsx | 9 ++ apps/wallet/src/ui/app/components/index.ts | 1 + .../app/components/receipt-card/StakeTxn.tsx | 57 -------- .../ui/app/components/receipt-card/index.tsx | 94 +++---------- .../transaction-request/index.tsx | 12 +- .../src/ui/app/pages/home/receipt/index.tsx | 29 ++-- .../app/shared/transaction-summary/index.tsx | 42 ------ .../src/ui/app/staking/stake/StakeForm.tsx | 10 +- apps/wallet/tailwind.config.ts | 6 +- apps/wallet/tests/balanceChanges.spec.ts | 2 +- 87 files changed, 1025 insertions(+), 960 deletions(-) create mode 100644 apps/core/src/components/buttons/ViewTxnOnExplorerButton.tsx create mode 100644 apps/core/src/components/buttons/index.ts rename apps/{wallet/src/ui/app/shared/transaction-summary => core/src/components}/cards/BalanceChanges.tsx (86%) rename apps/{wallet/src/ui/app/shared/transaction-summary/cards/objectSummary => core/src/components/cards}/ObjectChangeDisplay.tsx (59%) rename apps/{wallet/src/ui/app/shared/transaction-summary => core/src/components}/cards/ObjectChanges.tsx (81%) create mode 100644 apps/core/src/components/cards/index.ts rename apps/{wallet/src/ui/app/pages/approval-request/transaction-request => core/src/components/gas}/GasFees.tsx (76%) rename apps/{wallet/src/ui/app/shared/transaction-summary/cards => core/src/components/gas}/GasSummary.tsx (82%) create mode 100644 apps/core/src/components/gas/index.ts rename apps/{wallet/src/ui/app/shared => core/src/components/lists}/ExpandableList.tsx (87%) create mode 100644 apps/core/src/components/lists/index.ts create mode 100644 apps/core/src/components/transaction/TransactionReceipt.tsx create mode 100644 apps/core/src/components/transaction/amount/TransactionAmount.tsx create mode 100644 apps/core/src/components/transaction/amount/index.ts create mode 100644 apps/core/src/components/transaction/details/StakeTransactionDetails.tsx create mode 100644 apps/core/src/components/transaction/details/index.ts create mode 100644 apps/core/src/components/transaction/index.ts rename apps/{wallet/src/ui/app/components/receipt-card/StakeTxnInfo.tsx => core/src/components/transaction/info/StakeTransactionInfo.tsx} (69%) rename apps/{wallet/src/ui/app/components/receipt-card/UnstakeTxn.tsx => core/src/components/transaction/info/UnstakeTransactionInfo.tsx} (58%) create mode 100644 apps/core/src/components/transaction/info/index.ts create mode 100644 apps/core/src/components/transaction/summary/TransactionSummary.tsx create mode 100644 apps/core/src/components/transaction/summary/index.ts delete mode 100644 apps/core/src/hooks/useExtendedTransactionSummary.ts create mode 100644 apps/core/src/interfaces/balanceChange.interfaces.ts create mode 100644 apps/core/src/interfaces/index.ts create mode 100644 apps/core/src/interfaces/validatorLogo.interfaces.ts create mode 100644 apps/core/src/types/balanceChange.ts create mode 100644 apps/core/src/types/gasSummary.ts create mode 100644 apps/core/src/types/index.ts create mode 100644 apps/core/src/types/objectChange.ts create mode 100644 apps/core/src/types/renderComponent.ts create mode 100644 apps/core/src/types/transactionSummary.ts delete mode 100644 apps/core/src/utils/transaction/types.ts create mode 100644 apps/wallet-dashboard/components/Dialogs/Staking/enums/index.ts create mode 100644 apps/wallet-dashboard/components/Dialogs/Staking/enums/view.enums.ts create mode 100644 apps/wallet-dashboard/components/Dialogs/TransactionDialog.tsx rename apps/wallet-dashboard/components/Dialogs/{Staking/views/Layout.tsx => layout/DialogLayout.tsx} (76%) create mode 100644 apps/wallet-dashboard/components/Dialogs/layout/index.ts delete mode 100644 apps/wallet-dashboard/components/Popup/Popups/TransactionDetailsPopup.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/GasSummary.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntries.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/balance-changes/BalanceChangeEntry.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/balance-changes/BalanceChanges.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/balance-changes/index.ts delete mode 100644 apps/wallet-dashboard/components/transactions/object-changes/ObjectChangeEntry.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/object-changes/ObjectChanges.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/object-changes/ObjectDetail.tsx delete mode 100644 apps/wallet-dashboard/components/transactions/object-changes/index.ts create mode 100644 apps/wallet/src/ui/app/components/ExplorerLinkHelper.tsx delete mode 100644 apps/wallet/src/ui/app/components/receipt-card/StakeTxn.tsx delete mode 100644 apps/wallet/src/ui/app/shared/transaction-summary/index.tsx diff --git a/apps/core/src/components/buttons/ViewTxnOnExplorerButton.tsx b/apps/core/src/components/buttons/ViewTxnOnExplorerButton.tsx new file mode 100644 index 00000000000..247241de188 --- /dev/null +++ b/apps/core/src/components/buttons/ViewTxnOnExplorerButton.tsx @@ -0,0 +1,23 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import React, { JSX } from 'react'; +import { Button, ButtonType, LoadingIndicator } from '@iota/apps-ui-kit'; +import { ArrowTopRight } from '@iota/ui-icons'; + +interface ViewTxnOnExplorerButtonProps { + digest?: string; +} + +export function ViewTxnOnExplorerButton({ digest }: ViewTxnOnExplorerButtonProps): JSX.Element { + return ( +