From 8c622efe724e8c05e54453655b830a082979e791 Mon Sep 17 00:00:00 2001 From: yurixander <101931215+yurixander@users.noreply.github.com> Date: Sat, 30 Nov 2024 01:57:35 +0100 Subject: [PATCH 1/4] refactor(tangle-dapp): Cleanup and reorg --- apps/tangle-dapp/app/layout.tsx | 2 +- apps/tangle-dapp/app/liquid-staking/page.tsx | 6 +- .../NodeSpecificationsTable.tsx | 2 +- .../nomination/[validatorAddress]/page.tsx | 2 +- apps/tangle-dapp/app/nomination/page.tsx | 14 +- apps/tangle-dapp/app/page.tsx | 2 +- apps/tangle-dapp/app/restake/unstake/page.tsx | 1 - .../tangle-dapp/components/BnChartTooltip.tsx | 68 ----- .../BondedTokensBalanceInfo/index.ts | 1 - .../BondedTokensBalanceInfo/types.ts | 6 - .../components/HeaderChip/dataHooks.ts | 9 - .../components/HeaderChip/types.ts | 11 - .../components/HowItWorks/index.tsx | 100 ------ .../InputAction.tsx | 0 apps/tangle-dapp/components/InputWrapper.tsx | 23 +- .../components/KeyStatsItem/index.ts | 2 - .../LiquidStaking/LsMyPoolsTable.tsx | 2 +- .../LiquidStaking/LsProtocolDropdownInput.tsx | 2 +- .../{ => LiquidStaking}/LsTokenIcon.tsx | 0 .../LiquidStaking/LsUnbondingTable.tsx | 3 +- .../LiquidStaking/stakeAndUnstake/LsInput.tsx | 2 +- .../stakeAndUnstake/LsSelectLstModal.tsx | 4 +- .../stakeAndUnstake/LsTokenChip.tsx | 2 +- .../stakeAndUnstake/ProtocolSelector.tsx | 2 +- .../components/{ => Lists}/ListStatus.tsx | 0 .../index.tsx => NetworkSelectorButton.tsx} | 2 +- .../components/NominationsTable/index.ts | 1 - .../NominatorStatsItem/dataHooks.ts | 13 - .../components/NominatorStatsItem/index.ts | 1 - .../components/PayoutTable/index.ts | 1 - .../components/PayoutTable/types.ts | 11 - .../RestakeAssetDetailCard.tsx | 68 ----- .../RestakeOperatorDetailCard.tsx | 107 ------- .../components/RestakeDetailCard/index.tsx | 214 ------------- .../components/RestakeDetailCard/utils.ts | 13 - .../ServicesKeyMetricItem.tsx | 75 ----- .../components/ServicesKeyMetricItem/index.ts | 1 - .../components/ServicesKeyMetricItem/types.ts | 12 - .../{TableStatus => }/TableStatus.tsx | 15 +- .../components/TableStatus/index.ts | 1 - .../components/TableStatus/types.ts | 10 - .../components/UnbondingStatsItem/index.ts | 1 - .../components/ValidatorList/types.ts | 9 - .../ValidatorSelectionTable.tsx | 36 ++- .../ValidatorSelectionTable/index.ts | 1 - .../ValidatorSelectionTable/types.ts | 18 -- .../{ValidatorTable => }/ValidatorTable.tsx | 25 +- .../components/ValidatorTable/index.ts | 1 - .../components/ValidatorTable/types.ts | 7 - .../components/account/AccountSummaryCard.tsx | 4 +- .../BridgeTxQueueDropdown.tsx} | 0 .../BridgeTxQueueItem.tsx | 0 .../IndependentRoleDistributionChart.tsx | 97 ------ .../components/charts/RoleEarningsChart.tsx | 137 --------- .../charts/SharedRoleDistributionChart.tsx | 79 ----- apps/tangle-dapp/components/charts/index.ts | 3 - apps/tangle-dapp/components/charts/types.ts | 22 -- apps/tangle-dapp/components/charts/utils.ts | 10 - apps/tangle-dapp/components/index.ts | 16 +- .../BondedTokensBalanceInfo.tsx | 7 +- .../{ => nomination}/HeaderChip/ChipText.tsx | 4 +- .../HeaderChip/HeaderChip.tsx | 13 +- .../nomination/HeaderChip/dataHooks.ts | 9 + .../{ => nomination}/HeaderChip/index.ts | 0 .../KeyStatsItem.tsx | 0 .../NominationsTable.tsx | 0 .../NominatorStatsItem.tsx | 0 .../PayoutTable.tsx | 13 +- .../UnbondingStatsItem.tsx | 6 +- .../components/nomination/dataHooks.ts | 13 + .../components/skeleton/ContainerSkeleton.tsx | 6 +- .../{ => skeleton}/SkeletonRows.tsx | 0 apps/tangle-dapp/components/skeleton/types.ts | 4 - .../components/tableCells/HeaderCell.tsx | 8 +- .../components/tableCells/StringCell.tsx | 5 +- .../components/tableCells/types.ts | 13 - .../tables/Operators/VaultsDropdown.tsx | 2 +- .../components/tables/Operators/index.tsx | 2 +- .../components/tables/Operators/types.ts | 2 +- .../components/tables/Vaults/index.tsx | 4 +- .../components/tables/Vaults/types.ts | 2 +- apps/tangle-dapp/constants/env.ts | 1 - apps/tangle-dapp/constants/index.ts | 2 + .../{evmPrecompiles.ts => precompiles.ts} | 0 .../containers/BondMoreTxContainer/index.ts | 1 - .../containers/BondMoreTxContainer/types.ts | 11 - .../DebugMetrics.tsx | 2 +- .../containers/DebugMetricsContainer/index.ts | 1 - .../containers/DelegateTxContainer/index.ts | 1 - .../HeaderChipsContainer.tsx | 2 +- .../containers/HeaderChipsContainer/index.ts | 1 - .../containers/{Layout => }/Layout.tsx | 14 +- apps/tangle-dapp/containers/Layout/index.ts | 1 - .../AllocationChart.tsx | 175 ----------- .../AllocationStep.tsx | 66 ---- .../AllocationStepContainer.tsx | 26 -- .../ChooseMethodStep.tsx | 114 ------- .../ConfirmAllocationsStep.tsx | 222 -------------- .../IndependentAllocationInput.tsx | 184 ----------- .../Independent/IndependentAllocationStep.tsx | 202 ------------ .../ManageProfileModalContainer.tsx | 289 ------------------ .../Shared/SharedAllocationStep.tsx | 95 ------ .../Shared/SharedAmountInput.tsx | 84 ----- .../Shared/SharedRolesInput.tsx | 170 ----------- .../Shared/useSharedRestakeAmountState.ts | 17 -- .../ManageProfileModalContainer/index.ts | 1 - .../ManageProfileModalContainer/types.ts | 14 - .../useAllocationChartEntries.ts | 98 ------ .../useAllocationsState.ts | 26 -- .../NominationsPayoutsContainer/index.ts | 1 - .../NominatorStatsContainer/index.ts | 1 - .../containers/PayoutAllTxContainer/index.ts | 1 - .../containers/PayoutAllTxContainer/types.ts | 14 - .../containers/PayoutTxContainer/index.ts | 1 - .../containers/PayoutTxContainer/types.ts | 13 - .../containers/RebondTxContainer/index.ts | 1 - .../containers/RebondTxContainer/types.ts | 13 - .../StopNominationTxContainer/index.ts | 1 - .../StopNominationTxContainer/types.ts | 4 - .../containers/TransferTxContainer/index.ts | 1 - ...ferTxContainer.tsx => TransferTxModal.tsx} | 22 +- .../containers/UnbondTxContainer/index.ts | 1 - .../containers/UnbondTxContainer/types.ts | 11 - .../UpdatePayeeTxContainer/types.ts | 15 - .../ValidatorTableContainer.tsx | 6 - .../ValidatorTablesContainer/index.ts | 1 - .../WalletAndChainContainer.tsx | 2 +- .../WalletAndChainContainer/index.ts | 1 - .../WithdrawUnbondedTxContainer/index.ts | 1 - .../WithdrawUnbondedTxContainer/types.ts | 4 - .../balances}/BalanceAction.tsx | 2 +- .../balances}/BalanceCell.tsx | 4 +- .../balances}/BalancesTableContainer.tsx | 14 +- .../balances}/HeaderCell.tsx | 0 .../LockedBalanceDetails/DemocracyBalance.tsx | 2 +- .../DemocracyUnlockAction.tsx | 6 +- .../DemocracyUnlockingAt.tsx | 8 +- .../LockedBalanceDetails.tsx | 14 +- .../LockedBalanceDetails/TextCell.tsx | 0 .../VestingRemainingBalances.tsx | 2 +- .../VestingScheduleBalances.tsx | 4 +- .../VestingSchedulesUnlockingAt.tsx | 8 +- .../balances}/VestBalanceAction.tsx | 6 +- .../balances}/index.ts | 0 .../useLongestVestingScheduleTime.ts | 8 +- apps/tangle-dapp/containers/index.ts | 22 +- .../{ => liquidStaking}/LsCreatePoolModal.tsx | 27 +- .../LsMyProtocolsTable.tsx | 20 +- .../poolTables}/LsAllProtocolsTable.tsx | 18 +- .../poolTables}/LsPoolsTable.tsx | 22 +- .../poolTables}/index.ts | 0 .../ActiveAndWaitingValidatorTables.tsx} | 17 +- .../BondMoreTxContainer.tsx | 15 +- .../DelegateTxModal}/BondTokens.tsx | 10 +- .../DelegateTxModal/DelegateTxModal.tsx} | 26 +- .../nomination/DelegateTxModal/index.ts | 1 + .../DelegateTxModal}/types.ts | 4 +- .../ActiveValidatorsKeyStat.tsx | 4 +- .../ActualStakedPercentageKeyStat.tsx | 4 +- .../IdealStakedPercentageKeyStat.tsx | 4 +- .../InflationPercentageKeyStat.tsx | 4 +- .../KeyStatsContainer/KeyStatsContainer.tsx | 0 .../ValidatorCountKeyStat.tsx | 4 +- .../WaitingValidatorsKeyStat.tsx | 4 +- .../KeyStatsContainer/index.ts | 0 .../NominationsPayoutsContainer.tsx | 30 +- .../NominatorStatsContainer.tsx | 23 +- .../PayoutAllTxModal.tsx} | 19 +- .../PayoutTxModal.tsx} | 18 +- .../RebondTxModal.tsx} | 23 +- .../StopNominationTxModal.tsx} | 10 +- .../UnbondTxModal.tsx} | 21 +- .../SelectValidators.tsx | 4 +- .../UpdateNominationsTxContainer.tsx | 6 +- .../UpdateNominationsTxContainer/index.ts | 0 .../UpdatePayeeTxContainer/UpdatePayee.tsx | 14 +- .../UpdatePayeeTxContainer.tsx | 16 +- .../UpdatePayeeTxContainer/index.ts | 0 .../WithdrawUnbondedTxModal.tsx} | 20 +- apps/tangle-dapp/context/ErrorsContext.tsx | 52 ---- .../context/useOnboardingStore.tsx | 12 - .../context/useSearchParamsStore.ts | 68 ----- .../data/balances/useTransferTx.ts | 2 +- apps/tangle-dapp/data/index.ts | 2 +- .../liquidStaking/tangle/useLsCreatePoolTx.ts | 2 +- .../liquidStaking/tangle/useLsPoolJoinTx.ts | 2 +- .../liquidStaking/tangle/useLsPoolUnbondTx.ts | 2 +- .../liquidStaking/useLsWithdrawUnbondedTx.ts | 2 +- .../useNominations.ts | 2 +- .../useStakingRewardsDestination.ts | 0 .../useTokenWalletFreeBalance.ts | 0 .../useTotalPayoutRewards.ts | 0 .../useTotalStakedAmountSubscription.ts | 0 .../useUnbondedAmount.ts | 0 .../useUnbondingAmount.ts | 0 .../data/payouts/usePayoutAllTx.ts | 2 +- .../data/payouts/usePayoutStakersTx.ts | 2 +- .../usePayouts.ts | 8 +- .../tangle-dapp/data/restake/RestakeTx/evm.ts | 2 +- .../getProtocolEarningsChartData.ts | 16 - .../data/roleEarningsChart/index.ts | 1 - .../data/staking/useBondExtraTx.ts | 2 +- apps/tangle-dapp/data/staking/useChillTx.ts | 2 +- .../tangle-dapp/data/staking/useNominateTx.ts | 2 +- apps/tangle-dapp/data/staking/useRebondTx.ts | 2 +- .../tangle-dapp/data/staking/useSetPayeeTx.ts | 2 +- .../data/staking/useSetupNominatorTx.ts | 2 +- apps/tangle-dapp/data/staking/useUnbondTx.ts | 2 +- .../data/staking/useUpdateNominatorTx.ts | 2 +- .../data/staking/useWithdrawUnbondedTx.ts | 2 +- .../{ValidatorTables => validators}/index.ts | 0 .../useActiveValidators.ts | 0 .../useAllValidators.ts | 0 .../useValidatorIdentityNames.ts | 0 .../useValidators.ts | 0 .../useWaitingValidators.ts | 0 apps/tangle-dapp/data/vesting/useVestTx.ts | 2 +- apps/tangle-dapp/hooks/useAgnosticTx.ts | 2 +- .../hooks/useEvmPrecompileAbiCall.ts | 2 +- apps/tangle-dapp/hooks/useEvmPrecompileFee.ts | 2 +- .../utils/staking/createEvmBatchCallData.ts | 2 +- 221 files changed, 498 insertions(+), 3520 deletions(-) delete mode 100644 apps/tangle-dapp/components/BnChartTooltip.tsx delete mode 100644 apps/tangle-dapp/components/BondedTokensBalanceInfo/index.ts delete mode 100644 apps/tangle-dapp/components/BondedTokensBalanceInfo/types.ts delete mode 100644 apps/tangle-dapp/components/HeaderChip/dataHooks.ts delete mode 100644 apps/tangle-dapp/components/HeaderChip/types.ts delete mode 100644 apps/tangle-dapp/components/HowItWorks/index.tsx rename apps/tangle-dapp/{containers/ManageProfileModalContainer => components}/InputAction.tsx (100%) delete mode 100644 apps/tangle-dapp/components/KeyStatsItem/index.ts rename apps/tangle-dapp/components/{ => LiquidStaking}/LsTokenIcon.tsx (100%) rename apps/tangle-dapp/components/{ => Lists}/ListStatus.tsx (100%) rename apps/tangle-dapp/components/{NetworkSelectorButton/index.tsx => NetworkSelectorButton.tsx} (93%) delete mode 100644 apps/tangle-dapp/components/NominationsTable/index.ts delete mode 100644 apps/tangle-dapp/components/NominatorStatsItem/dataHooks.ts delete mode 100644 apps/tangle-dapp/components/NominatorStatsItem/index.ts delete mode 100644 apps/tangle-dapp/components/PayoutTable/index.ts delete mode 100644 apps/tangle-dapp/components/PayoutTable/types.ts delete mode 100644 apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx delete mode 100644 apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx delete mode 100644 apps/tangle-dapp/components/RestakeDetailCard/index.tsx delete mode 100644 apps/tangle-dapp/components/RestakeDetailCard/utils.ts delete mode 100644 apps/tangle-dapp/components/ServicesKeyMetricItem/ServicesKeyMetricItem.tsx delete mode 100644 apps/tangle-dapp/components/ServicesKeyMetricItem/index.ts delete mode 100644 apps/tangle-dapp/components/ServicesKeyMetricItem/types.ts rename apps/tangle-dapp/components/{TableStatus => }/TableStatus.tsx (86%) delete mode 100644 apps/tangle-dapp/components/TableStatus/index.ts delete mode 100644 apps/tangle-dapp/components/TableStatus/types.ts delete mode 100644 apps/tangle-dapp/components/UnbondingStatsItem/index.ts delete mode 100644 apps/tangle-dapp/components/ValidatorList/types.ts rename apps/tangle-dapp/components/{ValidatorSelectionTable => }/ValidatorSelectionTable.tsx (91%) delete mode 100644 apps/tangle-dapp/components/ValidatorSelectionTable/index.ts delete mode 100644 apps/tangle-dapp/components/ValidatorSelectionTable/types.ts rename apps/tangle-dapp/components/{ValidatorTable => }/ValidatorTable.tsx (91%) delete mode 100644 apps/tangle-dapp/components/ValidatorTable/index.ts delete mode 100644 apps/tangle-dapp/components/ValidatorTable/types.ts rename apps/tangle-dapp/components/{BridgeTxQueueDropdown/index.tsx => bridge/BridgeTxQueueDropdown.tsx} (100%) rename apps/tangle-dapp/components/{BridgeTxQueueDropdown => bridge}/BridgeTxQueueItem.tsx (100%) delete mode 100644 apps/tangle-dapp/components/charts/IndependentRoleDistributionChart.tsx delete mode 100644 apps/tangle-dapp/components/charts/RoleEarningsChart.tsx delete mode 100644 apps/tangle-dapp/components/charts/SharedRoleDistributionChart.tsx delete mode 100644 apps/tangle-dapp/components/charts/index.ts delete mode 100644 apps/tangle-dapp/components/charts/types.ts delete mode 100644 apps/tangle-dapp/components/charts/utils.ts rename apps/tangle-dapp/components/{BondedTokensBalanceInfo => nomination}/BondedTokensBalanceInfo.tsx (87%) rename apps/tangle-dapp/components/{ => nomination}/HeaderChip/ChipText.tsx (86%) rename apps/tangle-dapp/components/{ => nomination}/HeaderChip/HeaderChip.tsx (73%) create mode 100644 apps/tangle-dapp/components/nomination/HeaderChip/dataHooks.ts rename apps/tangle-dapp/components/{ => nomination}/HeaderChip/index.ts (100%) rename apps/tangle-dapp/components/{KeyStatsItem => nomination}/KeyStatsItem.tsx (100%) rename apps/tangle-dapp/components/{NominationsTable => nomination}/NominationsTable.tsx (100%) rename apps/tangle-dapp/components/{NominatorStatsItem => nomination}/NominatorStatsItem.tsx (100%) rename apps/tangle-dapp/components/{PayoutTable => nomination}/PayoutTable.tsx (96%) rename apps/tangle-dapp/components/{UnbondingStatsItem => nomination}/UnbondingStatsItem.tsx (91%) create mode 100644 apps/tangle-dapp/components/nomination/dataHooks.ts rename apps/tangle-dapp/components/{ => skeleton}/SkeletonRows.tsx (100%) delete mode 100644 apps/tangle-dapp/components/skeleton/types.ts delete mode 100644 apps/tangle-dapp/components/tableCells/types.ts delete mode 100644 apps/tangle-dapp/constants/env.ts rename apps/tangle-dapp/constants/{evmPrecompiles.ts => precompiles.ts} (100%) delete mode 100644 apps/tangle-dapp/containers/BondMoreTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/BondMoreTxContainer/types.ts rename apps/tangle-dapp/containers/{DebugMetricsContainer => }/DebugMetrics.tsx (98%) delete mode 100644 apps/tangle-dapp/containers/DebugMetricsContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/DelegateTxContainer/index.ts rename apps/tangle-dapp/containers/{HeaderChipsContainer => }/HeaderChipsContainer.tsx (87%) delete mode 100644 apps/tangle-dapp/containers/HeaderChipsContainer/index.ts rename apps/tangle-dapp/containers/{Layout => }/Layout.tsx (85%) delete mode 100644 apps/tangle-dapp/containers/Layout/index.ts delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationChart.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStep.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStepContainer.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/ChooseMethodStep.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/ConfirmAllocationsStep.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationInput.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationStep.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/ManageProfileModalContainer.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAllocationStep.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAmountInput.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedRolesInput.tsx delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/useSharedRestakeAmountState.ts delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationChartEntries.ts delete mode 100644 apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationsState.ts delete mode 100644 apps/tangle-dapp/containers/NominationsPayoutsContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/NominatorStatsContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/PayoutAllTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/PayoutAllTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/PayoutTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/PayoutTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/RebondTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/RebondTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/StopNominationTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/StopNominationTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/TransferTxContainer/index.ts rename apps/tangle-dapp/containers/{TransferTxContainer/TransferTxContainer.tsx => TransferTxModal.tsx} (91%) delete mode 100644 apps/tangle-dapp/containers/UnbondTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/UnbondTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/UpdatePayeeTxContainer/types.ts delete mode 100644 apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTableContainer.tsx delete mode 100644 apps/tangle-dapp/containers/ValidatorTablesContainer/index.ts rename apps/tangle-dapp/containers/{WalletAndChainContainer => }/WalletAndChainContainer.tsx (82%) delete mode 100644 apps/tangle-dapp/containers/WalletAndChainContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/index.ts delete mode 100644 apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/types.ts rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/BalanceAction.tsx (96%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/BalanceCell.tsx (93%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/BalancesTableContainer.tsx (94%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/HeaderCell.tsx (100%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/DemocracyBalance.tsx (84%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/DemocracyUnlockAction.tsx (81%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/DemocracyUnlockingAt.tsx (86%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/LockedBalanceDetails.tsx (92%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/TextCell.tsx (100%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/VestingRemainingBalances.tsx (95%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/VestingScheduleBalances.tsx (94%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx (88%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/VestBalanceAction.tsx (86%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/index.ts (100%) rename apps/tangle-dapp/containers/{BalancesTableContainer => account/balances}/useLongestVestingScheduleTime.ts (88%) rename apps/tangle-dapp/containers/{ => liquidStaking}/LsCreatePoolModal.tsx (89%) rename apps/tangle-dapp/containers/{ => liquidStaking}/LsMyProtocolsTable.tsx (91%) rename apps/tangle-dapp/containers/{LsPoolsTable => liquidStaking/poolTables}/LsAllProtocolsTable.tsx (90%) rename apps/tangle-dapp/containers/{LsPoolsTable => liquidStaking/poolTables}/LsPoolsTable.tsx (89%) rename apps/tangle-dapp/containers/{LsPoolsTable => liquidStaking/poolTables}/index.ts (100%) rename apps/tangle-dapp/containers/{ValidatorTablesContainer/ValidatorTablesContainer.tsx => nomination/ActiveAndWaitingValidatorTables.tsx} (85%) rename apps/tangle-dapp/containers/{BondMoreTxContainer => nomination}/BondMoreTxContainer.tsx (89%) rename apps/tangle-dapp/containers/{DelegateTxContainer => nomination/DelegateTxModal}/BondTokens.tsx (92%) rename apps/tangle-dapp/containers/{DelegateTxContainer/DelegateTxContainer.tsx => nomination/DelegateTxModal/DelegateTxModal.tsx} (90%) create mode 100644 apps/tangle-dapp/containers/nomination/DelegateTxModal/index.ts rename apps/tangle-dapp/containers/{DelegateTxContainer => nomination/DelegateTxModal}/types.ts (94%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/ActiveValidatorsKeyStat.tsx (76%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx (79%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx (80%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/InflationPercentageKeyStat.tsx (76%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/KeyStatsContainer.tsx (100%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/ValidatorCountKeyStat.tsx (81%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/WaitingValidatorsKeyStat.tsx (78%) rename apps/tangle-dapp/containers/{ => nomination}/KeyStatsContainer/index.ts (100%) rename apps/tangle-dapp/containers/{NominationsPayoutsContainer => nomination}/NominationsPayoutsContainer.tsx (94%) rename apps/tangle-dapp/containers/{NominatorStatsContainer => nomination}/NominatorStatsContainer.tsx (93%) rename apps/tangle-dapp/containers/{PayoutAllTxContainer/PayoutAllTxContainer.tsx => nomination/PayoutAllTxModal.tsx} (91%) rename apps/tangle-dapp/containers/{PayoutTxContainer/PayoutTxContainer.tsx => nomination/PayoutTxModal.tsx} (91%) rename apps/tangle-dapp/containers/{RebondTxContainer/RebondTxContainer.tsx => nomination/RebondTxModal.tsx} (84%) rename apps/tangle-dapp/containers/{StopNominationTxContainer/StopNominationTxContainer.tsx => nomination/StopNominationTxModal.tsx} (89%) rename apps/tangle-dapp/containers/{UnbondTxContainer/UnbondTxContainer.tsx => nomination/UnbondTxModal.tsx} (88%) rename apps/tangle-dapp/containers/{ => nomination}/UpdateNominationsTxContainer/SelectValidators.tsx (83%) rename apps/tangle-dapp/containers/{ => nomination}/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx (95%) rename apps/tangle-dapp/containers/{ => nomination}/UpdateNominationsTxContainer/index.ts (100%) rename apps/tangle-dapp/containers/{ => nomination}/UpdatePayeeTxContainer/UpdatePayee.tsx (78%) rename apps/tangle-dapp/containers/{ => nomination}/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx (81%) rename apps/tangle-dapp/containers/{ => nomination}/UpdatePayeeTxContainer/index.ts (100%) rename apps/tangle-dapp/containers/{WithdrawUnbondedTxContainer/WithdrawUnbondedTxContainer.tsx => nomination/WithdrawUnbondedTxModal.tsx} (83%) delete mode 100644 apps/tangle-dapp/context/ErrorsContext.tsx delete mode 100644 apps/tangle-dapp/context/useOnboardingStore.tsx delete mode 100644 apps/tangle-dapp/context/useSearchParamsStore.ts rename apps/tangle-dapp/data/{NominationsPayouts => nomination}/useNominations.ts (96%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useStakingRewardsDestination.ts (100%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useTokenWalletFreeBalance.ts (100%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useTotalPayoutRewards.ts (100%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useTotalStakedAmountSubscription.ts (100%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useUnbondedAmount.ts (100%) rename apps/tangle-dapp/data/{NominatorStats => nomination}/useUnbondingAmount.ts (100%) rename apps/tangle-dapp/data/{NominationsPayouts => payouts}/usePayouts.ts (96%) delete mode 100644 apps/tangle-dapp/data/roleEarningsChart/getProtocolEarningsChartData.ts delete mode 100644 apps/tangle-dapp/data/roleEarningsChart/index.ts rename apps/tangle-dapp/data/{ValidatorTables => validators}/index.ts (100%) rename apps/tangle-dapp/data/{ValidatorTables => validators}/useActiveValidators.ts (100%) rename apps/tangle-dapp/data/{ValidatorTables => validators}/useAllValidators.ts (100%) rename apps/tangle-dapp/data/{ValidatorTables => validators}/useValidatorIdentityNames.ts (100%) rename apps/tangle-dapp/data/{ValidatorTables => validators}/useValidators.ts (100%) rename apps/tangle-dapp/data/{ValidatorTables => validators}/useWaitingValidators.ts (100%) diff --git a/apps/tangle-dapp/app/layout.tsx b/apps/tangle-dapp/app/layout.tsx index a3e3b58af9..d1ed9d1f81 100644 --- a/apps/tangle-dapp/app/layout.tsx +++ b/apps/tangle-dapp/app/layout.tsx @@ -10,7 +10,7 @@ import type React from 'react'; import { cookieToInitialState } from 'wagmi'; import { DEFAULT_OPENGRAPH_METADATA } from '../constants/openGraph'; -import { Layout } from '../containers'; +import Layout from '../containers/Layout'; import Providers from './providers'; export const dynamic = 'force-static'; diff --git a/apps/tangle-dapp/app/liquid-staking/page.tsx b/apps/tangle-dapp/app/liquid-staking/page.tsx index 8a94ce23a9..4db4629519 100644 --- a/apps/tangle-dapp/app/liquid-staking/page.tsx +++ b/apps/tangle-dapp/app/liquid-staking/page.tsx @@ -16,9 +16,9 @@ import { FC, useEffect, useState } from 'react'; import LsUnbondingTable from '../../components/LiquidStaking/LsUnbondingTable'; import LsStakeCard from '../../components/LiquidStaking/stakeAndUnstake/LsStakeCard'; import LsUnstakeCard from '../../components/LiquidStaking/stakeAndUnstake/LsUnstakeCard'; -import LsCreatePoolModal from '../../containers/LsCreatePoolModal'; -import LsMyProtocolsTable from '../../containers/LsMyProtocolsTable'; -import { LsAllProtocolsTable } from '../../containers/LsPoolsTable'; +import LsCreatePoolModal from '../../containers/liquidStaking/LsCreatePoolModal'; +import LsMyProtocolsTable from '../../containers/liquidStaking/LsMyProtocolsTable'; +import { LsAllProtocolsTable } from '../../containers/liquidStaking/poolTables'; import { useLsStore } from '../../data/liquidStaking/useLsStore'; import useIsAccountConnected from '../../hooks/useIsAccountConnected'; import getLsTangleNetwork from '../../utils/liquidStaking/getLsTangleNetwork'; diff --git a/apps/tangle-dapp/app/nomination/[validatorAddress]/NodeSpecificationsTable.tsx b/apps/tangle-dapp/app/nomination/[validatorAddress]/NodeSpecificationsTable.tsx index 9ab9b97120..5f195fc374 100644 --- a/apps/tangle-dapp/app/nomination/[validatorAddress]/NodeSpecificationsTable.tsx +++ b/apps/tangle-dapp/app/nomination/[validatorAddress]/NodeSpecificationsTable.tsx @@ -13,9 +13,9 @@ import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/ty import cx from 'classnames'; import { FC } from 'react'; -import { TableStatus } from '../../../components'; import ContainerSkeleton from '../../../components/skeleton/ContainerSkeleton'; import { HeaderCell } from '../../../components/tableCells'; +import TableStatus from '../../../components/TableStatus'; import useNodeSpecifications from '../../../data/validatorDetails/useNodeSpecifications'; import { NodeSpecification } from '../../../types'; diff --git a/apps/tangle-dapp/app/nomination/[validatorAddress]/page.tsx b/apps/tangle-dapp/app/nomination/[validatorAddress]/page.tsx index a978c63011..8332d31a20 100644 --- a/apps/tangle-dapp/app/nomination/[validatorAddress]/page.tsx +++ b/apps/tangle-dapp/app/nomination/[validatorAddress]/page.tsx @@ -1,7 +1,7 @@ import { isAddress } from '@polkadot/util-crypto'; import { notFound } from 'next/navigation'; -import { IS_PRODUCTION_ENV } from '../../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../../constants'; import InfoCard from './InfoCard'; import NodeSpecificationsTable from './NodeSpecificationsTable'; diff --git a/apps/tangle-dapp/app/nomination/page.tsx b/apps/tangle-dapp/app/nomination/page.tsx index b983a9b685..d3f50cc0b1 100644 --- a/apps/tangle-dapp/app/nomination/page.tsx +++ b/apps/tangle-dapp/app/nomination/page.tsx @@ -2,13 +2,11 @@ import { Typography } from '@webb-tools/webb-ui-components'; import { Metadata } from 'next'; import { OpenGraphPageImageUrl } from '../../constants/openGraph'; -import { - HeaderChipsContainer, - KeyStatsContainer, - NominationsPayoutsContainer, - NominatorStatsContainer, - ValidatorTablesContainer, -} from '../../containers'; +import { KeyStatsContainer } from '../../containers'; +import HeaderChipsContainer from '../../containers/HeaderChipsContainer'; +import NominationsPayoutsContainer from '../../containers/nomination/NominationsPayoutsContainer'; +import NominatorStatsContainer from '../../containers/nomination/NominatorStatsContainer'; +import ActiveAndWaitingValidatorTables from '../../containers/nomination/ActiveAndWaitingValidatorTables'; import createPageMetadata from '../../utils/createPageMetadata'; export const dynamic = 'force-static'; @@ -37,7 +35,7 @@ export default function NominationPage() { - + ); } diff --git a/apps/tangle-dapp/app/page.tsx b/apps/tangle-dapp/app/page.tsx index d962b2e0b7..cb25ee0c71 100644 --- a/apps/tangle-dapp/app/page.tsx +++ b/apps/tangle-dapp/app/page.tsx @@ -3,7 +3,7 @@ import { Metadata } from 'next'; import { FC } from 'react'; import AccountSummaryCard from '../components/account/AccountSummaryCard'; -import BalancesTableContainer from '../containers/BalancesTableContainer/BalancesTableContainer'; +import BalancesTableContainer from '../containers/account/balances/BalancesTableContainer'; import createPageMetadata from '../utils/createPageMetadata'; export const dynamic = 'force-static'; diff --git a/apps/tangle-dapp/app/restake/unstake/page.tsx b/apps/tangle-dapp/app/restake/unstake/page.tsx index 3a190f37e9..abc08d12ff 100644 --- a/apps/tangle-dapp/app/restake/unstake/page.tsx +++ b/apps/tangle-dapp/app/restake/unstake/page.tsx @@ -24,7 +24,6 @@ import { formatUnits, parseUnits } from 'viem'; import AvatarWithText from '../../../components/AvatarWithText'; import ErrorMessage from '../../../components/ErrorMessage'; -import RestakeDetailCard from '../../../components/RestakeDetailCard'; import { SUPPORTED_RESTAKE_DEPOSIT_TYPED_CHAIN_IDS } from '../../../constants/restake'; import { useRestakeContext } from '../../../context/RestakeContext'; import { diff --git a/apps/tangle-dapp/components/BnChartTooltip.tsx b/apps/tangle-dapp/components/BnChartTooltip.tsx deleted file mode 100644 index e45d29be1c..0000000000 --- a/apps/tangle-dapp/components/BnChartTooltip.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { assert, BN } from '@polkadot/util'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; -import { TooltipProps } from 'recharts'; -import { z } from 'zod'; - -import { RestakingAllocationMap } from '../containers/ManageProfileModalContainer/types'; -import { AllocationChartEntryName } from '../containers/ManageProfileModalContainer/useAllocationChartEntries'; -import { RestakingService } from '../types'; -import formatTangleBalance from '../utils/formatTangleBalance'; - -const BnChartTooltip = ( - allocations: RestakingAllocationMap, - maxAmount: BN, - allocatedAmount: BN, - previewAmount: BN, - displayAmount: boolean, -) => { - const { nativeTokenSymbol } = useNetworkStore(); - - const composition = ({ active, payload }: TooltipProps) => { - if (!active || payload === undefined || payload.length === 0) { - return null; - } - - // Validate the label, since for some reason it has - // type `any` in the payload object. - const entryName: AllocationChartEntryName = z - .union([ - z.literal('Remaining' satisfies AllocationChartEntryName), - z.literal('New Allocation' satisfies AllocationChartEntryName), - z.nativeEnum(RestakingService), - ]) - .parse(payload[0].payload.name); - - const remainingAmount = maxAmount.sub(allocatedAmount).sub(previewAmount); - - const amount = - entryName === 'Remaining' - ? remainingAmount - : entryName === 'New Allocation' - ? previewAmount - : allocations[entryName]; - - assert( - amount !== undefined, - 'Service type should have an allocated amount in the allocation map', - ); - - return ( -
- - {entryName} - - {displayAmount && - `: ${formatTangleBalance(amount, nativeTokenSymbol)}`} - -
- ); - }; - - return composition; -}; - -export default BnChartTooltip; diff --git a/apps/tangle-dapp/components/BondedTokensBalanceInfo/index.ts b/apps/tangle-dapp/components/BondedTokensBalanceInfo/index.ts deleted file mode 100644 index 7d1962830a..0000000000 --- a/apps/tangle-dapp/components/BondedTokensBalanceInfo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './BondedTokensBalanceInfo'; diff --git a/apps/tangle-dapp/components/BondedTokensBalanceInfo/types.ts b/apps/tangle-dapp/components/BondedTokensBalanceInfo/types.ts deleted file mode 100644 index df4db5f86f..0000000000 --- a/apps/tangle-dapp/components/BondedTokensBalanceInfo/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BN } from '@polkadot/util'; - -export type BondedTokensBalanceInfoProps = { - type: 'unbonded' | 'unbonding'; - value: BN; -}; diff --git a/apps/tangle-dapp/components/HeaderChip/dataHooks.ts b/apps/tangle-dapp/components/HeaderChip/dataHooks.ts deleted file mode 100644 index 15bad3c25c..0000000000 --- a/apps/tangle-dapp/components/HeaderChip/dataHooks.ts +++ /dev/null @@ -1,9 +0,0 @@ -import useEraCountSubscription from '../../data/useEraCountSubscription'; -import useSessionCountSubscription from '../../data/useSessionCountSubscription'; - -const dataHooks = { - ERA: useEraCountSubscription, - Session: useSessionCountSubscription, -} as const; - -export default dataHooks; diff --git a/apps/tangle-dapp/components/HeaderChip/types.ts b/apps/tangle-dapp/components/HeaderChip/types.ts deleted file mode 100644 index d5cc3643f7..0000000000 --- a/apps/tangle-dapp/components/HeaderChip/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { IconBase } from '@webb-tools/icons/types'; -import type React from 'react'; - -export type ChipType = 'ERA' | 'Session'; - -export interface HeaderChipItemProps { - Icon: (props: IconBase) => React.JSX.Element; - label: ChipType; - hasTooltip?: boolean; - tooltipContent?: string; -} diff --git a/apps/tangle-dapp/components/HowItWorks/index.tsx b/apps/tangle-dapp/components/HowItWorks/index.tsx deleted file mode 100644 index dd6b8f95cc..0000000000 --- a/apps/tangle-dapp/components/HowItWorks/index.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import isPrimitive from '@webb-tools/dapp-types/utils/isPrimitive'; -import { ExternalLinkLine } from '@webb-tools/icons'; -import Button from '@webb-tools/webb-ui-components/components/buttons/Button'; -import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; -import { - type ComponentProps, - type ComponentType, - forwardRef, - type ReactNode, - type SVGAttributes, -} from 'react'; -import { twMerge } from 'tailwind-merge'; - -type HowItWorksProps = ComponentProps<'div'> & { - docsUrl?: string; -}; - -const HowItWorks = forwardRef( - ({ children, className, docsUrl, ...props }, ref) => { - return ( -
- - How it works - - -
{children}
- - {docsUrl && ( - - )} -
- ); - }, -); - -HowItWorks.displayName = 'HowItWorks'; - -type HowItWorksStepProps = ComponentProps<'div'> & { - Icon: ComponentType, 'children'>>; - title: ReactNode; - description: ReactNode; -}; - -const HowItWorksStep = forwardRef( - ({ Icon, title, description, className, ...props }, ref) => { - return ( -
- - -
- {isPrimitive(title) ? ( - - {title} - - ) : ( - title - )} - - {isPrimitive(description) ? ( - - {description} - - ) : ( - description - )} -
-
- ); - }, -); - -HowItWorksStep.displayName = 'HowItWorksStep'; - -export type { HowItWorksProps, HowItWorksStepProps }; - -export { HowItWorks, HowItWorksStep }; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/InputAction.tsx b/apps/tangle-dapp/components/InputAction.tsx similarity index 100% rename from apps/tangle-dapp/containers/ManageProfileModalContainer/InputAction.tsx rename to apps/tangle-dapp/components/InputAction.tsx diff --git a/apps/tangle-dapp/components/InputWrapper.tsx b/apps/tangle-dapp/components/InputWrapper.tsx index 6bb5b8958c..c1e6f88a66 100644 --- a/apps/tangle-dapp/components/InputWrapper.tsx +++ b/apps/tangle-dapp/components/InputWrapper.tsx @@ -5,19 +5,11 @@ import { InfoIconWithTooltip, Label, } from '@webb-tools/webb-ui-components'; -import { - Dispatch, - FC, - ReactNode, - SetStateAction, - useCallback, - useEffect, -} from 'react'; +import { Dispatch, FC, ReactNode, SetStateAction, useCallback } from 'react'; import { twMerge } from 'tailwind-merge'; -import InputAction from '../containers/ManageProfileModalContainer/InputAction'; -import { useErrorCountContext } from '../context/ErrorsContext'; import ErrorMessage from './ErrorMessage'; +import InputAction from './InputAction'; export type InputWrapperProps = { title: string; @@ -58,23 +50,12 @@ const InputWrapper: FC = ({ isDisabled = false, tooltip, }) => { - const { addError, removeError } = useErrorCountContext(); - const toggleDropdown = useCallback(() => { if (dropdownBody !== undefined && setIsDropdownVisible !== undefined) { setIsDropdownVisible((isVisible) => !isVisible); } }, [dropdownBody, setIsDropdownVisible]); - // TODO: Do not set error (or remove it if already set) if the input is disabled. - useEffect(() => { - if (errorMessage !== undefined) { - addError(id); - } else { - removeError(id); - } - }, [addError, errorMessage, id, removeError]); - // Do not consider the input as having an error if it's disabled. const hasError = errorMessage !== undefined && !isDisabled; diff --git a/apps/tangle-dapp/components/KeyStatsItem/index.ts b/apps/tangle-dapp/components/KeyStatsItem/index.ts deleted file mode 100644 index 858b4ba712..0000000000 --- a/apps/tangle-dapp/components/KeyStatsItem/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './KeyStatsItem'; -export { default as KeyStatsItem } from './KeyStatsItem'; diff --git a/apps/tangle-dapp/components/LiquidStaking/LsMyPoolsTable.tsx b/apps/tangle-dapp/components/LiquidStaking/LsMyPoolsTable.tsx index 2c94caef8a..1cdf40d351 100644 --- a/apps/tangle-dapp/components/LiquidStaking/LsMyPoolsTable.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/LsMyPoolsTable.tsx @@ -37,10 +37,10 @@ import { AmountFormatStyle } from '../../utils/formatDisplayAmount'; import getLsProtocolDef from '../../utils/liquidStaking/getLsProtocolDef'; import tryEncodeAddressWithPrefix from '../../utils/liquidStaking/tryEncodeAddressWithPrefix'; import pluralize from '../../utils/pluralize'; -import { TableStatus } from '..'; import BlueIconButton from '../BlueIconButton'; import PercentageCell from '../tableCells/PercentageCell'; import TokenAmountCell from '../tableCells/TokenAmountCell'; +import TableStatus from '../TableStatus'; import LstIcon from './LstIcon'; import UpdateCommissionModal from './UpdateCommissionModal'; diff --git a/apps/tangle-dapp/components/LiquidStaking/LsProtocolDropdownInput.tsx b/apps/tangle-dapp/components/LiquidStaking/LsProtocolDropdownInput.tsx index fd3954489a..9791693baf 100644 --- a/apps/tangle-dapp/components/LiquidStaking/LsProtocolDropdownInput.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/LsProtocolDropdownInput.tsx @@ -16,7 +16,7 @@ import getLsNetwork from '../../utils/liquidStaking/getLsNetwork'; import getLsProtocolDef from '../../utils/liquidStaking/getLsProtocolDef'; import DropdownChevronIcon from '../DropdownChevronIcon'; import InputWrapper from '../InputWrapper'; -import LsTokenIcon from '../LsTokenIcon'; +import LsTokenIcon from './LsTokenIcon'; type LsProtocolDropdownInputProps = { id: string; diff --git a/apps/tangle-dapp/components/LsTokenIcon.tsx b/apps/tangle-dapp/components/LiquidStaking/LsTokenIcon.tsx similarity index 100% rename from apps/tangle-dapp/components/LsTokenIcon.tsx rename to apps/tangle-dapp/components/LiquidStaking/LsTokenIcon.tsx diff --git a/apps/tangle-dapp/components/LiquidStaking/LsUnbondingTable.tsx b/apps/tangle-dapp/components/LiquidStaking/LsUnbondingTable.tsx index 5a257a582c..ffd5e5f783 100644 --- a/apps/tangle-dapp/components/LiquidStaking/LsUnbondingTable.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/LsUnbondingTable.tsx @@ -22,8 +22,9 @@ import useLsUnbonding from '../../data/liquidStaking/useLsUnbonding'; import useIsAccountConnected from '../../hooks/useIsAccountConnected'; import addCommasToNumber from '../../utils/addCommasToNumber'; import pluralize from '../../utils/pluralize'; -import { ContainerSkeleton, TableStatus } from '..'; +import { ContainerSkeleton } from '..'; import TokenAmountCell from '../tableCells/TokenAmountCell'; +import TableStatus from '../TableStatus'; import LstIcon from './LstIcon'; import WithdrawUnstakeRequestButton from './WithdrawUnstakeRequestButton'; diff --git a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsInput.tsx b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsInput.tsx index 2c49c6b414..fae324c259 100644 --- a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsInput.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsInput.tsx @@ -7,7 +7,7 @@ import { twMerge } from 'tailwind-merge'; import { LS_DERIVATIVE_TOKEN_PREFIX } from '../../../constants/liquidStaking/constants'; import { LsNetworkId, LsToken } from '../../../constants/liquidStaking/types'; -import { ERROR_NOT_ENOUGH_BALANCE } from '../../../containers/ManageProfileModalContainer/Independent/IndependentAllocationInput'; +import { ERROR_NOT_ENOUGH_BALANCE } from '../../../containers/liquidStaking/LsCreatePoolModal'; import { useLsStore } from '../../../data/liquidStaking/useLsStore'; import useInputAmount from '../../../hooks/useInputAmount'; import formatBn from '../../../utils/formatBn'; diff --git a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsSelectLstModal.tsx b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsSelectLstModal.tsx index 149440e646..e468f7fcc1 100644 --- a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsSelectLstModal.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsSelectLstModal.tsx @@ -19,8 +19,8 @@ import formatBn from '../../../utils/formatBn'; import formatFractional from '../../../utils/formatFractional'; import getLsProtocolDef from '../../../utils/liquidStaking/getLsProtocolDef'; import { ListCardWrapper } from '../../Lists/ListCardWrapper'; -import ListStatus from '../../ListStatus'; -import SkeletonRows from '../../SkeletonRows'; +import ListStatus from '../../Lists/ListStatus'; +import SkeletonRows from '../../skeleton/SkeletonRows'; import LstIcon, { LstIconSize } from '../LstIcon'; export type LsSelectLstModalProps = { diff --git a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsTokenChip.tsx b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsTokenChip.tsx index d86725bda8..a9eeb04f46 100644 --- a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsTokenChip.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsTokenChip.tsx @@ -5,7 +5,7 @@ import { twMerge } from 'tailwind-merge'; import { LS_DERIVATIVE_TOKEN_PREFIX } from '../../../constants/liquidStaking/constants'; import { LsToken } from '../../../constants/liquidStaking/types'; import DropdownChevronIcon from '../../DropdownChevronIcon'; -import LsTokenIcon from '../../LsTokenIcon'; +import LsTokenIcon from '../LsTokenIcon'; type LsTokenChipProps = { token?: LsToken; diff --git a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/ProtocolSelector.tsx b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/ProtocolSelector.tsx index fa527d9ad3..f3a49e03de 100644 --- a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/ProtocolSelector.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/ProtocolSelector.tsx @@ -15,7 +15,7 @@ import { LsNetworkId } from '../../../constants/liquidStaking/types'; import getLsNetwork from '../../../utils/liquidStaking/getLsNetwork'; import getLsProtocolDef from '../../../utils/liquidStaking/getLsProtocolDef'; import DropdownChevronIcon from '../../DropdownChevronIcon'; -import LsTokenIcon from '../../LsTokenIcon'; +import LsTokenIcon from '../LsTokenIcon'; type ProtocolSelectorProps = { selectedNetworkId: LsNetworkId; diff --git a/apps/tangle-dapp/components/ListStatus.tsx b/apps/tangle-dapp/components/Lists/ListStatus.tsx similarity index 100% rename from apps/tangle-dapp/components/ListStatus.tsx rename to apps/tangle-dapp/components/Lists/ListStatus.tsx diff --git a/apps/tangle-dapp/components/NetworkSelectorButton/index.tsx b/apps/tangle-dapp/components/NetworkSelectorButton.tsx similarity index 93% rename from apps/tangle-dapp/components/NetworkSelectorButton/index.tsx rename to apps/tangle-dapp/components/NetworkSelectorButton.tsx index a390187ff3..c64b805ff3 100644 --- a/apps/tangle-dapp/components/NetworkSelectorButton/index.tsx +++ b/apps/tangle-dapp/components/NetworkSelectorButton.tsx @@ -4,7 +4,7 @@ import NetworkSelectorDropdown from '@webb-tools/tangle-shared-ui/components/Net import { usePathname } from 'next/navigation'; import { type FC } from 'react'; -import { PagePath } from '../../types'; +import { PagePath } from '../types'; const NetworkSelectorButton: FC = () => { const pathname = usePathname(); diff --git a/apps/tangle-dapp/components/NominationsTable/index.ts b/apps/tangle-dapp/components/NominationsTable/index.ts deleted file mode 100644 index c766fd6e33..0000000000 --- a/apps/tangle-dapp/components/NominationsTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as NominationsTable } from './NominationsTable'; diff --git a/apps/tangle-dapp/components/NominatorStatsItem/dataHooks.ts b/apps/tangle-dapp/components/NominatorStatsItem/dataHooks.ts deleted file mode 100644 index 424c5fdbde..0000000000 --- a/apps/tangle-dapp/components/NominatorStatsItem/dataHooks.ts +++ /dev/null @@ -1,13 +0,0 @@ -import useTokenWalletFreeBalance from '../../data/NominatorStats/useTokenWalletFreeBalance'; -import useTotalPayoutRewards from '../../data/NominatorStats/useTotalPayoutRewards'; -import useTotalStakedAmountSubscription from '../../data/NominatorStats/useTotalStakedAmountSubscription'; -import useUnbondingAmountSubscription from '../../data/NominatorStats/useUnbondingAmount'; - -const dataHooks = { - 'Wallet Balance': useTokenWalletFreeBalance, - 'Total Staked': useTotalStakedAmountSubscription, - 'Unbonding Amount': useUnbondingAmountSubscription, - 'Total Payout Rewards': useTotalPayoutRewards, -} as const; - -export default dataHooks; diff --git a/apps/tangle-dapp/components/NominatorStatsItem/index.ts b/apps/tangle-dapp/components/NominatorStatsItem/index.ts deleted file mode 100644 index 454698b849..0000000000 --- a/apps/tangle-dapp/components/NominatorStatsItem/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './NominatorStatsItem'; diff --git a/apps/tangle-dapp/components/PayoutTable/index.ts b/apps/tangle-dapp/components/PayoutTable/index.ts deleted file mode 100644 index f1ce8755b4..0000000000 --- a/apps/tangle-dapp/components/PayoutTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PayoutTable } from './PayoutTable'; diff --git a/apps/tangle-dapp/components/PayoutTable/types.ts b/apps/tangle-dapp/components/PayoutTable/types.ts deleted file mode 100644 index a913b8b764..0000000000 --- a/apps/tangle-dapp/components/PayoutTable/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { DeriveSessionProgress } from '@polkadot/api-derive/types'; -import { BN } from '@polkadot/util'; -import { Payout } from '@webb-tools/tangle-shared-ui/types'; - -export interface PayoutTableProps { - data?: Payout[]; - pageSize: number; - sessionProgress: DeriveSessionProgress | null; - historyDepth: BN | null; - epochDuration: number | null; -} diff --git a/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx b/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx deleted file mode 100644 index cba8fbd99d..0000000000 --- a/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { ArrowRightUp } from '@webb-tools/icons/ArrowRightUp'; -import { TokenIcon } from '@webb-tools/icons/TokenIcon'; -import Button from '@webb-tools/webb-ui-components/components/buttons/Button'; - -import RestakeDetailCard from './index'; -import { getDisplayValue } from './utils'; - -type RestakeAssetDetailCardProps = { - assetExternalLink?: string; - getAssetLink?: string; - limit?: string | number; - name?: string; - symbol?: string; - tvl?: string | number; -}; - -const RestakeAssetDetailCard = ({ - assetExternalLink, - getAssetLink, - limit, - name, - symbol, - tvl, -}: RestakeAssetDetailCardProps) => { - return ( - - - } - RightElement={ - getAssetLink ? ( - - ) : undefined - } - title={symbol} - description={name} - descExternalLink={assetExternalLink} - /> - - - - {getDisplayValue(tvl)} - - - - {getDisplayValue(limit)} - - - - ); -}; - -export default RestakeAssetDetailCard; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx b/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx deleted file mode 100644 index 71dcdad0ca..0000000000 --- a/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx +++ /dev/null @@ -1,107 +0,0 @@ -'use client'; - -import GlobalLine from '@webb-tools/icons/GlobalLine'; -import { Mail } from '@webb-tools/icons/Mail'; -import MapPinLine from '@webb-tools/icons/MapPinLine'; -import { TwitterFill } from '@webb-tools/icons/TwitterFill'; -import { Avatar } from '@webb-tools/webb-ui-components/components/Avatar'; -import { Chip } from '@webb-tools/webb-ui-components/components/Chip'; -import { KeyValueWithButton } from '@webb-tools/webb-ui-components/components/KeyValueWithButton'; -import { shortenString } from '@webb-tools/webb-ui-components/utils/shortenString'; -import { cloneElement, ReactElement } from 'react'; - -import RestakeDetailCard from './index'; -import { getDisplayValue } from './utils'; - -type RestakeOperatorDetailCardProps = { - delegationCount?: number; - identityEmailLink?: string; - identityName?: string; - identityWebLink?: string; - identityXLink?: string; - isDelegated?: boolean; - operatorAccountId?: string; - totalStaked?: string | number; - validatorExternalLink?: string; - location?: string; -}; - -const RestakeOperatorDetailCard = ({ - delegationCount, - identityEmailLink, - identityName, - identityXLink, - identityWebLink, - isDelegated, - operatorAccountId = '', - totalStaked, - validatorExternalLink, - location = 'Unknown', -}: RestakeOperatorDetailCardProps) => { - return ( - - - } - RightElement={ - isDelegated ? DELEGATED : undefined - } - title={identityName || shortenString(operatorAccountId ?? '')} - description={ - - } - descExternalLink={validatorExternalLink} - /> - - - - {getDisplayValue(totalStaked)} - - - - {getDisplayValue(delegationCount)} - - - -
-
- {identityXLink && ( - } /> - )} - - {identityEmailLink && ( - } /> - )} - - {identityWebLink && ( - } /> - )} -
- - - - - {location} - -
-
- ); -}; - -export default RestakeOperatorDetailCard; - -const SocialLink = ({ href, Icon }: { href?: string; Icon: ReactElement }) => { - return ( - - - {cloneElement(Icon, { className: '!fill-current' })} - - - ); -}; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/index.tsx b/apps/tangle-dapp/components/RestakeDetailCard/index.tsx deleted file mode 100644 index 0fb9a81a0b..0000000000 --- a/apps/tangle-dapp/components/RestakeDetailCard/index.tsx +++ /dev/null @@ -1,214 +0,0 @@ -import { isPrimitive } from '@webb-tools/dapp-types'; -import { ExternalLinkLine } from '@webb-tools/icons/ExternalLinkLine'; -import { TitleWithInfo } from '@webb-tools/webb-ui-components/components/TitleWithInfo'; -import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; -import { - type ComponentProps, - ForwardedRef, - forwardRef, - type JSXElementConstructor, - type ReactElement, - type ReactNode, -} from 'react'; -import { twMerge } from 'tailwind-merge'; - -type ElementBase = string | JSXElementConstructor; - -type RestakeDetailCardRootProps = ComponentProps<'div'>; - -const RestakeDetailCardRoot = forwardRef< - HTMLDivElement, - RestakeDetailCardRootProps ->(({ className, children, ...props }, ref) => { - return ( -
- {children} -
- ); -}); - -RestakeDetailCardRoot.displayName = 'RestakeDetailCardRoot'; - -type RestakeDetailCardHeaderProps< - IconProps, - RightElementProps, - IconElement extends ElementBase = ElementBase, - RightElement extends ElementBase = ElementBase, -> = ComponentProps<'div'> & { - IconElement?: ReactElement; - title?: ReactNode; - description?: ReactNode; - descExternalLink?: string; - RightElement?: ReactElement; -}; - -const RestakeDetailCardHeader = forwardRef( - < - IconProps, - RightElementProps, - IconEl extends ElementBase = ElementBase, - RightEl extends ElementBase = ElementBase, - >( - { - className, - title, - description, - descExternalLink, - RightElement, - IconElement, - ...props - }: RestakeDetailCardHeaderProps< - IconProps, - RightElementProps, - IconEl, - RightEl - >, - ref: ForwardedRef, - ) => { - return ( -
-
- {IconElement} - -
- {isPrimitive(title) && title !== null && title !== undefined ? ( - - {title} - - ) : ( - title - )} - -
- {isPrimitive(description) && - description !== null && - description !== undefined ? ( - - {description} - - ) : ( - description - )} - - {descExternalLink && ( - - - - )} -
-
-
- - {RightElement} -
- ); - }, -); - -RestakeDetailCardHeader.displayName = 'RestakeDetailCardHeader'; - -type RestakeDetailCardBodyProps = ComponentProps<'div'>; - -const RestakeDetailCardBody = forwardRef< - HTMLDivElement, - RestakeDetailCardBodyProps ->(({ className, children, ...props }, ref) => { - return ( -
- {children} -
- ); -}); - -RestakeDetailCardBody.displayName = 'RestakeDetailCardBody'; - -type RestakeDetailCardItemProps = ComponentProps<'div'> & { - title: string; - tooltip?: ReactNode; -}; - -const RestakeDetailCardItem = forwardRef< - HTMLDivElement, - RestakeDetailCardItemProps ->(({ className, title, tooltip, children, ...props }, ref) => { - return ( -
- {isPrimitive(children) ? ( - - {children} - - ) : ( - children - )} - - -
- ); -}); - -RestakeDetailCardItem.displayName = 'RestakeDetailCardItem'; - -const RestakeDetailCard = Object.assign( - {}, - { - Root: RestakeDetailCardRoot, - Header: RestakeDetailCardHeader, - Body: RestakeDetailCardBody, - Item: RestakeDetailCardItem, - }, -); - -export type { - RestakeDetailCardBodyProps, - RestakeDetailCardHeaderProps, - RestakeDetailCardItemProps, - RestakeDetailCardRootProps, -}; - -export { - RestakeDetailCardBody, - RestakeDetailCardHeader, - RestakeDetailCardItem, - RestakeDetailCardRoot, -}; - -export default RestakeDetailCard; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/utils.ts b/apps/tangle-dapp/components/RestakeDetailCard/utils.ts deleted file mode 100644 index bcee727b14..0000000000 --- a/apps/tangle-dapp/components/RestakeDetailCard/utils.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; - -export function getDisplayValue(val?: string | number): string { - if (typeof val === 'string') { - return val; - } - - if (typeof val === 'number') { - return val.toLocaleString('en-US'); - } - - return EMPTY_VALUE_PLACEHOLDER; -} diff --git a/apps/tangle-dapp/components/ServicesKeyMetricItem/ServicesKeyMetricItem.tsx b/apps/tangle-dapp/components/ServicesKeyMetricItem/ServicesKeyMetricItem.tsx deleted file mode 100644 index 6134b71b10..0000000000 --- a/apps/tangle-dapp/components/ServicesKeyMetricItem/ServicesKeyMetricItem.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { ArrowRight } from '@webb-tools/icons'; -import { SkeletonLoader, Typography } from '@webb-tools/webb-ui-components'; -import { getRoundedAmountString } from '@webb-tools/webb-ui-components/utils'; -import { FC } from 'react'; -import { twMerge } from 'tailwind-merge'; - -import { ServicesKeyMetricItemProps } from './types'; - -const ServicesKeyMetricItem: FC = ({ - title, - Icon, - isLoading, - isError, - value, - changeRate, - className, -}) => { - return ( -
-
- - {title} - - - {/* Icon */} -
- -
- -
- {isLoading ? ( - - ) : ( -
- {/* Value */} - - {typeof value === 'number' && !isError ? value : 'Error'} - - - {/* Change Rate */} - {typeof changeRate === 'number' && - Number.isFinite(changeRate) && - !Number.isNaN(changeRate) && ( -
- = 0 ? '!text-green-70' : '!text-red-70', - )} - > - {changeRate >= 0 ? `+` : `-`} - {getRoundedAmountString(Math.abs(changeRate), 2)}% - - = 0 - ? '!fill-green-70 rotate-[-90deg]' - : '!fill-red-70 rotate-90', - )} - /> -
- )} -
- )} -
- ); -}; - -export default ServicesKeyMetricItem; diff --git a/apps/tangle-dapp/components/ServicesKeyMetricItem/index.ts b/apps/tangle-dapp/components/ServicesKeyMetricItem/index.ts deleted file mode 100644 index 4189bf462b..0000000000 --- a/apps/tangle-dapp/components/ServicesKeyMetricItem/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as ServicesKeyMetricItem } from './ServicesKeyMetricItem'; diff --git a/apps/tangle-dapp/components/ServicesKeyMetricItem/types.ts b/apps/tangle-dapp/components/ServicesKeyMetricItem/types.ts deleted file mode 100644 index 69bb707e4c..0000000000 --- a/apps/tangle-dapp/components/ServicesKeyMetricItem/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { IconBase } from '@webb-tools/icons/types'; -import { ReactElement } from 'react'; - -export interface ServicesKeyMetricItemProps { - title: string; - Icon: (props: IconBase) => ReactElement; - isLoading: boolean; - isError?: boolean; - value?: number | null; - changeRate?: number | null; - className?: string; -} diff --git a/apps/tangle-dapp/components/TableStatus/TableStatus.tsx b/apps/tangle-dapp/components/TableStatus.tsx similarity index 86% rename from apps/tangle-dapp/components/TableStatus/TableStatus.tsx rename to apps/tangle-dapp/components/TableStatus.tsx index 57494edb55..1f65a01c92 100644 --- a/apps/tangle-dapp/components/TableStatus/TableStatus.tsx +++ b/apps/tangle-dapp/components/TableStatus.tsx @@ -1,7 +1,18 @@ -import { Button, Typography } from '@webb-tools/webb-ui-components'; +import { + Button, + ButtonProps, + Typography, +} from '@webb-tools/webb-ui-components'; import { twMerge } from 'tailwind-merge'; -import { TableStatusProps } from './types'; +export type TableStatusProps = { + icon?: string; + title: string; + description: string; + buttonText?: string; + buttonProps?: ButtonProps; + className?: string; +}; const GRID_BACKGROUND_CLASS = twMerge( 'relative px-6 py-10 rounded-2xl !bg-[unset] border-mono-0 dark:border-mono-160 backdrop-blur-2xl', diff --git a/apps/tangle-dapp/components/TableStatus/index.ts b/apps/tangle-dapp/components/TableStatus/index.ts deleted file mode 100644 index fc95feeb98..0000000000 --- a/apps/tangle-dapp/components/TableStatus/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as TableStatus } from './TableStatus'; diff --git a/apps/tangle-dapp/components/TableStatus/types.ts b/apps/tangle-dapp/components/TableStatus/types.ts deleted file mode 100644 index 42ec3d816b..0000000000 --- a/apps/tangle-dapp/components/TableStatus/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ButtonProps } from '@webb-tools/webb-ui-components'; - -export type TableStatusProps = { - icon?: string; - title: string; - description: string; - buttonText?: string; - buttonProps?: ButtonProps; - className?: string; -}; diff --git a/apps/tangle-dapp/components/UnbondingStatsItem/index.ts b/apps/tangle-dapp/components/UnbondingStatsItem/index.ts deleted file mode 100644 index 84aacff504..0000000000 --- a/apps/tangle-dapp/components/UnbondingStatsItem/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as UnbondingStatsItem } from './UnbondingStatsItem'; diff --git a/apps/tangle-dapp/components/ValidatorList/types.ts b/apps/tangle-dapp/components/ValidatorList/types.ts deleted file mode 100644 index aa1a9e7c96..0000000000 --- a/apps/tangle-dapp/components/ValidatorList/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { Dispatch, SetStateAction } from 'react'; - -import type { Validator } from '../../types'; - -export interface ValidatorListTableProps { - data: Validator[]; - pageSize: number; - setSelectedValidators: Dispatch>>; -} diff --git a/apps/tangle-dapp/components/ValidatorSelectionTable/ValidatorSelectionTable.tsx b/apps/tangle-dapp/components/ValidatorSelectionTable.tsx similarity index 91% rename from apps/tangle-dapp/components/ValidatorSelectionTable/ValidatorSelectionTable.tsx rename to apps/tangle-dapp/components/ValidatorSelectionTable.tsx index cf05a26bc3..9903ce38b8 100644 --- a/apps/tangle-dapp/components/ValidatorSelectionTable/ValidatorSelectionTable.tsx +++ b/apps/tangle-dapp/components/ValidatorSelectionTable.tsx @@ -29,7 +29,9 @@ import { import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types'; import cx from 'classnames'; import React, { + Dispatch, FC, + SetStateAction, startTransition, useEffect, useMemo, @@ -37,19 +39,33 @@ import React, { useState, } from 'react'; -import { Validator } from '../../types'; -import calculateCommission from '../../utils/calculateCommission'; -import { AmountFormatStyle } from '../../utils/formatDisplayAmount'; -import formatFractional from '../../utils/formatFractional'; -import pluralize from '../../utils/pluralize'; +import { Validator } from '../types'; +import calculateCommission from '../utils/calculateCommission'; +import { AmountFormatStyle } from '../utils/formatDisplayAmount'; +import formatFractional from '../utils/formatFractional'; +import pluralize from '../utils/pluralize'; import { getSortAddressOrIdentityFnc, sortBnValueForNomineeOrValidator, -} from '../../utils/table'; -import { ContainerSkeleton } from '..'; -import { HeaderCell } from '../tableCells'; -import TokenAmountCell from '../tableCells/TokenAmountCell'; -import { ValidatorSelectionTableProps } from './types'; +} from '../utils/table'; +import { ContainerSkeleton } from '.'; +import { HeaderCell } from './tableCells'; +import TokenAmountCell from './tableCells/TokenAmountCell'; + +export type ValidatorSelectionTableProps = { + allValidators: Validator[]; + isLoading: boolean; + defaultSelectedValidators: string[]; + setSelectedValidators: Dispatch>>; + pageSize?: number; +}; + +export type SortBy = 'asc' | 'dsc'; + +export type SortableKeys = keyof Pick< + Validator, + 'commission' | 'nominatorCount' | 'totalStakeAmount' +>; const columnHelper = createColumnHelper(); diff --git a/apps/tangle-dapp/components/ValidatorSelectionTable/index.ts b/apps/tangle-dapp/components/ValidatorSelectionTable/index.ts deleted file mode 100644 index 41c135ba1a..0000000000 --- a/apps/tangle-dapp/components/ValidatorSelectionTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as ValidatorSelectionTable } from './ValidatorSelectionTable'; diff --git a/apps/tangle-dapp/components/ValidatorSelectionTable/types.ts b/apps/tangle-dapp/components/ValidatorSelectionTable/types.ts deleted file mode 100644 index ceceb505c1..0000000000 --- a/apps/tangle-dapp/components/ValidatorSelectionTable/types.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Dispatch, SetStateAction } from 'react'; - -import { Validator } from '../../types'; - -export type ValidatorSelectionTableProps = { - allValidators: Validator[]; - isLoading: boolean; - defaultSelectedValidators: string[]; - setSelectedValidators: Dispatch>>; - pageSize?: number; -}; - -export type SortBy = 'asc' | 'dsc'; - -export type SortableKeys = keyof Pick< - Validator, - 'commission' | 'nominatorCount' | 'totalStakeAmount' ->; diff --git a/apps/tangle-dapp/components/ValidatorTable/ValidatorTable.tsx b/apps/tangle-dapp/components/ValidatorTable.tsx similarity index 91% rename from apps/tangle-dapp/components/ValidatorTable/ValidatorTable.tsx rename to apps/tangle-dapp/components/ValidatorTable.tsx index a3a68cbc2e..2068b45f79 100644 --- a/apps/tangle-dapp/components/ValidatorTable/ValidatorTable.tsx +++ b/apps/tangle-dapp/components/ValidatorTable.tsx @@ -26,19 +26,24 @@ import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/ty import Link from 'next/link'; import { FC, useMemo, useState } from 'react'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; -import { PagePath, Validator } from '../../types'; -import calculateCommission from '../../utils/calculateCommission'; -import { AmountFormatStyle } from '../../utils/formatDisplayAmount'; -import pluralize from '../../utils/pluralize'; +import { IS_PRODUCTION_ENV } from '../constants'; +import { PagePath, Validator } from '../types'; +import calculateCommission from '../utils/calculateCommission'; +import { AmountFormatStyle } from '../utils/formatDisplayAmount'; +import pluralize from '../utils/pluralize'; import { getSortAddressOrIdentityFnc, sortBnValueForNomineeOrValidator, -} from '../../utils/table'; -import { HeaderCell, StringCell } from '../tableCells'; -import PercentageCell from '../tableCells/PercentageCell'; -import TokenAmountCell from '../tableCells/TokenAmountCell'; -import { ValidatorTableProps } from './types'; +} from '../utils/table'; +import { HeaderCell, StringCell } from './tableCells'; +import PercentageCell from './tableCells/PercentageCell'; +import TokenAmountCell from './tableCells/TokenAmountCell'; + +export interface ValidatorTableProps { + isWaiting?: boolean; + data: Validator[]; + searchValue?: string; +} const columnHelper = createColumnHelper(); diff --git a/apps/tangle-dapp/components/ValidatorTable/index.ts b/apps/tangle-dapp/components/ValidatorTable/index.ts deleted file mode 100644 index c9fd5babb0..0000000000 --- a/apps/tangle-dapp/components/ValidatorTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as ValidatorTable } from './ValidatorTable'; diff --git a/apps/tangle-dapp/components/ValidatorTable/types.ts b/apps/tangle-dapp/components/ValidatorTable/types.ts deleted file mode 100644 index 3a064ea907..0000000000 --- a/apps/tangle-dapp/components/ValidatorTable/types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Validator } from '../../types'; - -export interface ValidatorTableProps { - isWaiting?: boolean; - data: Validator[]; - searchValue?: string; -} diff --git a/apps/tangle-dapp/components/account/AccountSummaryCard.tsx b/apps/tangle-dapp/components/account/AccountSummaryCard.tsx index 609cc43dd6..53984e739f 100644 --- a/apps/tangle-dapp/components/account/AccountSummaryCard.tsx +++ b/apps/tangle-dapp/components/account/AccountSummaryCard.tsx @@ -2,7 +2,7 @@ import { FC, useState } from 'react'; -import TransferTxContainer from '../../containers/TransferTxContainer/TransferTxContainer'; +import TransferTxModal from '../../containers/TransferTxModal'; import GlassCardWithLogo from '../GlassCardWithLogo'; import AccountAddress from './AccountAddress'; import Actions from './Actions'; @@ -31,7 +31,7 @@ const AccountSummaryCard: FC<{ className?: string }> = ({ className }) => { * the card due to the backdrop filter applied to the glass card * due to some internal CSS logic regarding stacking contexts. */} - diff --git a/apps/tangle-dapp/components/BridgeTxQueueDropdown/index.tsx b/apps/tangle-dapp/components/bridge/BridgeTxQueueDropdown.tsx similarity index 100% rename from apps/tangle-dapp/components/BridgeTxQueueDropdown/index.tsx rename to apps/tangle-dapp/components/bridge/BridgeTxQueueDropdown.tsx diff --git a/apps/tangle-dapp/components/BridgeTxQueueDropdown/BridgeTxQueueItem.tsx b/apps/tangle-dapp/components/bridge/BridgeTxQueueItem.tsx similarity index 100% rename from apps/tangle-dapp/components/BridgeTxQueueDropdown/BridgeTxQueueItem.tsx rename to apps/tangle-dapp/components/bridge/BridgeTxQueueItem.tsx diff --git a/apps/tangle-dapp/components/charts/IndependentRoleDistributionChart.tsx b/apps/tangle-dapp/components/charts/IndependentRoleDistributionChart.tsx deleted file mode 100644 index e0690cba4e..0000000000 --- a/apps/tangle-dapp/components/charts/IndependentRoleDistributionChart.tsx +++ /dev/null @@ -1,97 +0,0 @@ -'use client'; - -import { BN, BN_ZERO } from '@polkadot/util'; -import { Typography, useNextDarkMode } from '@webb-tools/webb-ui-components'; -import { FC, useMemo } from 'react'; -import { Cell, Pie, PieChart, Tooltip } from 'recharts'; -import { twMerge } from 'tailwind-merge'; - -import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; -import type { PieChartProps } from './types'; -import { formatDataForPieCharts } from './utils'; - -const IndependentRoleDistributionChart: FC = ({ - data, - title = 'Independent', -}) => { - const [isDarkMode] = useNextDarkMode(); - const formatNativeTokenAmount = useFormatNativeTokenAmount(); - - const hasData = useMemo(() => data.length > 0, [data]); - - const dataOrDefault = useMemo(() => { - return hasData - ? formatDataForPieCharts(data) - : [{ value: 1, color: isDarkMode ? '#3A3E53' : '#D3D8E2' }]; - }, [hasData, data, isDarkMode]); - - return ( -
- - 1 ? 5 : 0} - outerRadius={100} - dataKey="value" - > - {dataOrDefault.map((item, index) => ( - - ))} - - - {hasData && ( - { - if (active && payload && payload.length) { - return ( - - ); - } - }} - wrapperStyle={{ zIndex: 100 }} - cursor={false} - /> - )} - - -
- {title} - - {formatNativeTokenAmount( - data.reduce((acc, item) => acc.add(new BN(item.value)), BN_ZERO), - )} - -
-
- ); -}; - -export default IndependentRoleDistributionChart; - -/** @internal */ -const TooltipContent: FC<{ - name: string; - value: string; -}> = ({ name, value }) => { - return ( -
- - {name}: {value} - -
- ); -}; diff --git a/apps/tangle-dapp/components/charts/RoleEarningsChart.tsx b/apps/tangle-dapp/components/charts/RoleEarningsChart.tsx deleted file mode 100644 index 26f2e54587..0000000000 --- a/apps/tangle-dapp/components/charts/RoleEarningsChart.tsx +++ /dev/null @@ -1,137 +0,0 @@ -'use client'; - -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { - getRoundedAmountString, - Typography, - useNextDarkMode, -} from '@webb-tools/webb-ui-components'; -import { FC, useMemo } from 'react'; -import { - Bar, - BarChart, - CartesianGrid, - ResponsiveContainer, - Tooltip, - XAxis, - YAxis, -} from 'recharts'; - -import { ChartColor } from '../../constants'; -import type { RoleEarningsChartProps } from './types'; - -const RoleEarningsChart: FC = ({ data }) => { - const [isDarkMode] = useNextDarkMode(); - const { nativeTokenSymbol } = useNetworkStore(); - - const isEmptyData = useMemo(() => data.length === 0, [data]); - - return ( -
- - - - - getRoundedAmountString(value)} - tick={{ - fontSize: '12px', - fill: isDarkMode ? '#C2C8D4' : '#1F1D2B', - fontWeight: 400, - }} - tickLine={{ stroke: isDarkMode ? '#3A3E53' : '#D3D8E2' }} - /> - { - if (active && payload && payload.length) { - return ( - - ); - } - }} - /> - - - - - {isEmptyData && ( -
- - No Earnings to Display - -
- )} -
- ); -}; - -// TODO: remove this later -// Suppress the warning about missing defaultProps in recharts library -// @link https://github.com/recharts/recharts/issues/3615 -// temporary solution: https://github.com/recharts/recharts/issues/3615#issuecomment-1947814453 -const error = console.error; -console.error = (...args: any) => { - if (/defaultProps/.test(args[0])) return; - error(...args); -}; - -export default RoleEarningsChart; - -/** @internal */ -const TooltipContent = ({ - era, - reward, - suffix, -}: { - era: number; - reward: number; - suffix?: string; -}) => { - return ( -
- - Era: {era} - - -
-
- - - Reward: {getRoundedAmountString(reward)} {suffix ?? ''} - -
-
- ); -}; diff --git a/apps/tangle-dapp/components/charts/SharedRoleDistributionChart.tsx b/apps/tangle-dapp/components/charts/SharedRoleDistributionChart.tsx deleted file mode 100644 index 2df8e3b1ac..0000000000 --- a/apps/tangle-dapp/components/charts/SharedRoleDistributionChart.tsx +++ /dev/null @@ -1,79 +0,0 @@ -'use client'; - -import { Typography } from '@webb-tools/webb-ui-components'; -import { FC } from 'react'; -import { Cell, RadialBar, RadialBarChart, Tooltip } from 'recharts'; -import { twMerge } from 'tailwind-merge'; - -import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; -import type { PieChartProps } from './types'; -import { formatDataForPieCharts } from './utils'; - -const SharedRoleDistributionChart: FC = ({ - data, - title = 'Shared', -}) => { - const formatNativeTokenAmount = useFormatNativeTokenAmount(); - - const formattedData = formatDataForPieCharts(data); - - return ( -
- - - {data.map((item, index) => ( - - ))} - - { - if (active && payload && payload.length) { - return ; - } - }} - wrapperStyle={{ zIndex: 100 }} - cursor={false} - /> - - -
- {title} - - {/* In Shared Profile, all roles share the same value */} - {formatNativeTokenAmount(data[0].value)} - -
-
- ); -}; - -export default SharedRoleDistributionChart; - -/** @internal */ -const TooltipContent: FC<{ - name: string; -}> = ({ name }) => { - return ( -
- - {name} - -
- ); -}; diff --git a/apps/tangle-dapp/components/charts/index.ts b/apps/tangle-dapp/components/charts/index.ts deleted file mode 100644 index bd99e3afcc..0000000000 --- a/apps/tangle-dapp/components/charts/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { default as IndependentRoleDistributionChart } from './IndependentRoleDistributionChart'; -export { default as RoleEarningsChart } from './RoleEarningsChart'; -export { default as SharedRoleDistributionChart } from './SharedRoleDistributionChart'; diff --git a/apps/tangle-dapp/components/charts/types.ts b/apps/tangle-dapp/components/charts/types.ts deleted file mode 100644 index 2f95b2075e..0000000000 --- a/apps/tangle-dapp/components/charts/types.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { BN } from '@polkadot/util'; - -export type PieChartItem = { - name: string; - value: BN; - color: string; -}; - -export interface PieChartProps { - data: PieChartItem[]; - title?: string; -} - -export type RoleEarningsChartItem = { - era: number; - // TODO: might need to change from number to BN here - reward: number; -}; - -export interface RoleEarningsChartProps { - data: RoleEarningsChartItem[]; -} diff --git a/apps/tangle-dapp/components/charts/utils.ts b/apps/tangle-dapp/components/charts/utils.ts deleted file mode 100644 index 9ff61c5234..0000000000 --- a/apps/tangle-dapp/components/charts/utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PieChartItem } from './types'; - -export function formatDataForPieCharts(data: PieChartItem[]) { - return data.map((item) => ({ - ...item, - // Recharts only receive number as value type - // this might be a problem with BN that are out of range of JS - value: +item.value.toString(), - })); -} diff --git a/apps/tangle-dapp/components/index.ts b/apps/tangle-dapp/components/index.ts index 6cd3844f26..edc7817960 100644 --- a/apps/tangle-dapp/components/index.ts +++ b/apps/tangle-dapp/components/index.ts @@ -1,16 +1,14 @@ -export * from './BondedTokensBalanceInfo'; -export { default as BridgeTxQueueDropdown } from './BridgeTxQueueDropdown'; +export { default as BridgeTxQueueDropdown } from './bridge/BridgeTxQueueDropdown'; export { default as GlassCardWithLogo } from './GlassCardWithLogo'; -export * from './HeaderChip'; -export * from './KeyStatsItem'; -export * from './NominationsTable'; -export * from './NominatorStatsItem'; -export * from './PayoutTable'; -export * from './ServicesKeyMetricItem'; +export * from './nomination/BondedTokensBalanceInfo'; +export * from './nomination/HeaderChip'; +export * from './nomination/KeyStatsItem'; +export * from './nomination/NominationsTable'; +export * from './nomination/PayoutTable'; +export * from './nomination/UnbondingStatsItem'; export * from './Sidebar'; export * from './skeleton'; export * from './TableStatus'; export { default as TangleBigLogo } from './TangleBigLogo'; -export * from './UnbondingStatsItem'; export * from './ValidatorSelectionTable'; export * from './ValidatorTable'; diff --git a/apps/tangle-dapp/components/BondedTokensBalanceInfo/BondedTokensBalanceInfo.tsx b/apps/tangle-dapp/components/nomination/BondedTokensBalanceInfo.tsx similarity index 87% rename from apps/tangle-dapp/components/BondedTokensBalanceInfo/BondedTokensBalanceInfo.tsx rename to apps/tangle-dapp/components/nomination/BondedTokensBalanceInfo.tsx index fc5a843a52..2d8be795fa 100644 --- a/apps/tangle-dapp/components/BondedTokensBalanceInfo/BondedTokensBalanceInfo.tsx +++ b/apps/tangle-dapp/components/nomination/BondedTokensBalanceInfo.tsx @@ -1,10 +1,15 @@ +import { BN } from '@polkadot/util'; import { LockUnlockLineIcon, TimeLineIcon } from '@webb-tools/icons'; import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; import { Typography } from '@webb-tools/webb-ui-components'; import { type FC } from 'react'; import formatTangleBalance from '../../utils/formatTangleBalance'; -import { BondedTokensBalanceInfoProps } from './types'; + +export type BondedTokensBalanceInfoProps = { + type: 'unbonded' | 'unbonding'; + value: BN; +}; export const BondedTokensBalanceInfo: FC = ({ type, diff --git a/apps/tangle-dapp/components/HeaderChip/ChipText.tsx b/apps/tangle-dapp/components/nomination/HeaderChip/ChipText.tsx similarity index 86% rename from apps/tangle-dapp/components/HeaderChip/ChipText.tsx rename to apps/tangle-dapp/components/nomination/HeaderChip/ChipText.tsx index 462b57415f..f79b252faf 100644 --- a/apps/tangle-dapp/components/HeaderChip/ChipText.tsx +++ b/apps/tangle-dapp/components/nomination/HeaderChip/ChipText.tsx @@ -3,9 +3,9 @@ import { Typography } from '@webb-tools/webb-ui-components'; import SkeletonLoader from '@webb-tools/webb-ui-components/components/SkeletonLoader'; -import addCommasToNumber from '../../utils/addCommasToNumber'; +import addCommasToNumber from '../../../utils/addCommasToNumber'; import dataHooks from './dataHooks'; -import type { HeaderChipItemProps } from './types'; +import { HeaderChipItemProps } from './HeaderChip'; type Props = Pick; diff --git a/apps/tangle-dapp/components/HeaderChip/HeaderChip.tsx b/apps/tangle-dapp/components/nomination/HeaderChip/HeaderChip.tsx similarity index 73% rename from apps/tangle-dapp/components/HeaderChip/HeaderChip.tsx rename to apps/tangle-dapp/components/nomination/HeaderChip/HeaderChip.tsx index 98b0c83892..4335536999 100644 --- a/apps/tangle-dapp/components/HeaderChip/HeaderChip.tsx +++ b/apps/tangle-dapp/components/nomination/HeaderChip/HeaderChip.tsx @@ -1,3 +1,4 @@ +import { IconBase } from '@webb-tools/icons/types'; import { Chip, Tooltip, @@ -5,10 +6,18 @@ import { TooltipTrigger, Typography, } from '@webb-tools/webb-ui-components'; -import { type FC, useMemo } from 'react'; +import React, { type FC, useMemo } from 'react'; import ChipText from './ChipText'; -import { HeaderChipItemProps } from './types'; + +export type ChipType = 'ERA' | 'Session'; + +export interface HeaderChipItemProps { + Icon: (props: IconBase) => React.JSX.Element; + label: ChipType; + hasTooltip?: boolean; + tooltipContent?: string; +} export const HeaderChip: FC = ({ Icon, diff --git a/apps/tangle-dapp/components/nomination/HeaderChip/dataHooks.ts b/apps/tangle-dapp/components/nomination/HeaderChip/dataHooks.ts new file mode 100644 index 0000000000..5d29e243de --- /dev/null +++ b/apps/tangle-dapp/components/nomination/HeaderChip/dataHooks.ts @@ -0,0 +1,9 @@ +import useEraCountSubscription from '../../../data/useEraCountSubscription'; +import useSessionCountSubscription from '../../../data/useSessionCountSubscription'; + +const dataHooks = { + ERA: useEraCountSubscription, + Session: useSessionCountSubscription, +} as const; + +export default dataHooks; diff --git a/apps/tangle-dapp/components/HeaderChip/index.ts b/apps/tangle-dapp/components/nomination/HeaderChip/index.ts similarity index 100% rename from apps/tangle-dapp/components/HeaderChip/index.ts rename to apps/tangle-dapp/components/nomination/HeaderChip/index.ts diff --git a/apps/tangle-dapp/components/KeyStatsItem/KeyStatsItem.tsx b/apps/tangle-dapp/components/nomination/KeyStatsItem.tsx similarity index 100% rename from apps/tangle-dapp/components/KeyStatsItem/KeyStatsItem.tsx rename to apps/tangle-dapp/components/nomination/KeyStatsItem.tsx diff --git a/apps/tangle-dapp/components/NominationsTable/NominationsTable.tsx b/apps/tangle-dapp/components/nomination/NominationsTable.tsx similarity index 100% rename from apps/tangle-dapp/components/NominationsTable/NominationsTable.tsx rename to apps/tangle-dapp/components/nomination/NominationsTable.tsx diff --git a/apps/tangle-dapp/components/NominatorStatsItem/NominatorStatsItem.tsx b/apps/tangle-dapp/components/nomination/NominatorStatsItem.tsx similarity index 100% rename from apps/tangle-dapp/components/NominatorStatsItem/NominatorStatsItem.tsx rename to apps/tangle-dapp/components/nomination/NominatorStatsItem.tsx diff --git a/apps/tangle-dapp/components/PayoutTable/PayoutTable.tsx b/apps/tangle-dapp/components/nomination/PayoutTable.tsx similarity index 96% rename from apps/tangle-dapp/components/PayoutTable/PayoutTable.tsx rename to apps/tangle-dapp/components/nomination/PayoutTable.tsx index 42e35224eb..8e12de924a 100644 --- a/apps/tangle-dapp/components/PayoutTable/PayoutTable.tsx +++ b/apps/tangle-dapp/components/nomination/PayoutTable.tsx @@ -28,13 +28,20 @@ import { import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/types'; import { type FC, useState } from 'react'; -import PayoutTxContainer from '../../containers/PayoutTxContainer/PayoutTxContainer'; +import PayoutTxModal from '../../containers/nomination/PayoutTxModal'; import { AmountFormatStyle } from '../../utils/formatDisplayAmount'; import pluralize from '../../utils/pluralize'; import { sortBnValueForPayout } from '../../utils/table'; import { HeaderCell, StringCell } from '../tableCells'; import TokenAmountCell from '../tableCells/TokenAmountCell'; -import { PayoutTableProps } from './types'; + +export interface PayoutTableProps { + data?: Payout[]; + pageSize: number; + sessionProgress: DeriveSessionProgress | null; + historyDepth: BN | null; + epochDuration: number | null; +} const columnHelper = createColumnHelper(); @@ -252,7 +259,7 @@ const PayoutTable: FC = ({ />
- { const activeAccountAddress = useActiveAccountAddress(); diff --git a/apps/tangle-dapp/components/nomination/dataHooks.ts b/apps/tangle-dapp/components/nomination/dataHooks.ts new file mode 100644 index 0000000000..beb60f23a4 --- /dev/null +++ b/apps/tangle-dapp/components/nomination/dataHooks.ts @@ -0,0 +1,13 @@ +import useTokenWalletFreeBalance from '../../data/nomination/useTokenWalletFreeBalance'; +import useTotalPayoutRewards from '../../data/nomination/useTotalPayoutRewards'; +import useTotalStakedAmountSubscription from '../../data/nomination/useTotalStakedAmountSubscription'; +import useUnbondingAmountSubscription from '../../data/nomination/useUnbondingAmount'; + +const dataHooks = { + 'Wallet Balance': useTokenWalletFreeBalance, + 'Total Staked': useTotalStakedAmountSubscription, + 'Unbonding Amount': useUnbondingAmountSubscription, + 'Total Payout Rewards': useTotalPayoutRewards, +} as const; + +export default dataHooks; diff --git a/apps/tangle-dapp/components/skeleton/ContainerSkeleton.tsx b/apps/tangle-dapp/components/skeleton/ContainerSkeleton.tsx index 3fb9f9008f..a165ba5d1a 100644 --- a/apps/tangle-dapp/components/skeleton/ContainerSkeleton.tsx +++ b/apps/tangle-dapp/components/skeleton/ContainerSkeleton.tsx @@ -2,7 +2,11 @@ import { type FC } from 'react'; import { twMerge } from 'tailwind-merge'; import SkeletonRow from './SkeletonRow'; -import { ContainerSkeletonProps } from './types'; + +export interface ContainerSkeletonProps { + numOfRows?: number; + className?: string; +} const ContainerSkeleton: FC = ({ numOfRows = 4, diff --git a/apps/tangle-dapp/components/SkeletonRows.tsx b/apps/tangle-dapp/components/skeleton/SkeletonRows.tsx similarity index 100% rename from apps/tangle-dapp/components/SkeletonRows.tsx rename to apps/tangle-dapp/components/skeleton/SkeletonRows.tsx diff --git a/apps/tangle-dapp/components/skeleton/types.ts b/apps/tangle-dapp/components/skeleton/types.ts deleted file mode 100644 index 09f6c5f1ad..0000000000 --- a/apps/tangle-dapp/components/skeleton/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ContainerSkeletonProps { - numOfRows?: number; - className?: string; -} diff --git a/apps/tangle-dapp/components/tableCells/HeaderCell.tsx b/apps/tangle-dapp/components/tableCells/HeaderCell.tsx index c312946ffa..dd56b614e5 100644 --- a/apps/tangle-dapp/components/tableCells/HeaderCell.tsx +++ b/apps/tangle-dapp/components/tableCells/HeaderCell.tsx @@ -2,10 +2,16 @@ import { InfoIconWithTooltip, Typography, } from '@webb-tools/webb-ui-components'; +import { WebbTypographyVariant } from '@webb-tools/webb-ui-components/typography/types'; import { FC } from 'react'; import { twMerge } from 'tailwind-merge'; -import { HeaderCellProps } from './types'; +export interface HeaderCellProps { + title: string; + tooltip?: string; + className?: string; + titleVariant?: WebbTypographyVariant; +} const HeaderCell: FC = ({ title, diff --git a/apps/tangle-dapp/components/tableCells/StringCell.tsx b/apps/tangle-dapp/components/tableCells/StringCell.tsx index 2205f5796e..0887e6d9a6 100644 --- a/apps/tangle-dapp/components/tableCells/StringCell.tsx +++ b/apps/tangle-dapp/components/tableCells/StringCell.tsx @@ -2,7 +2,10 @@ import { Typography } from '@webb-tools/webb-ui-components'; import { FC } from 'react'; import { twMerge } from 'tailwind-merge'; -import { StringCellProps } from './types'; +export interface StringCellProps { + value: string; + className?: string; +} const StringCell: FC = ({ value, className }) => { return ( diff --git a/apps/tangle-dapp/components/tableCells/types.ts b/apps/tangle-dapp/components/tableCells/types.ts deleted file mode 100644 index fe36ce1c7c..0000000000 --- a/apps/tangle-dapp/components/tableCells/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { WebbTypographyVariant } from '@webb-tools/webb-ui-components/typography/types'; - -export interface HeaderCellProps { - title: string; - tooltip?: string; - className?: string; - titleVariant?: WebbTypographyVariant; -} - -export interface StringCellProps { - value: string; - className?: string; -} diff --git a/apps/tangle-dapp/components/tables/Operators/VaultsDropdown.tsx b/apps/tangle-dapp/components/tables/Operators/VaultsDropdown.tsx index 66820e333f..986c7c38f7 100644 --- a/apps/tangle-dapp/components/tables/Operators/VaultsDropdown.tsx +++ b/apps/tangle-dapp/components/tables/Operators/VaultsDropdown.tsx @@ -15,7 +15,7 @@ import { getRoundedAmountString } from '@webb-tools/webb-ui-components/utils/get import cx from 'classnames'; import { FC } from 'react'; -import LsTokenIcon from '../../LsTokenIcon'; +import LsTokenIcon from '../../LiquidStaking/LsTokenIcon'; import type { VaultToken } from './types'; const columnHelper = createColumnHelper(); diff --git a/apps/tangle-dapp/components/tables/Operators/index.tsx b/apps/tangle-dapp/components/tables/Operators/index.tsx index 45f1baaebc..f7ac789dc0 100644 --- a/apps/tangle-dapp/components/tables/Operators/index.tsx +++ b/apps/tangle-dapp/components/tables/Operators/index.tsx @@ -26,7 +26,7 @@ import formatFractional from '../../../utils/formatFractional'; import getTVLToDisplay from '../../../utils/getTVLToDisplay'; import pluralize from '../../../utils/pluralize'; import { getSortAddressOrIdentityFnc } from '../../../utils/table'; -import { TableStatus } from '../../TableStatus'; +import TableStatus from '../../TableStatus'; import TableCellWrapper from '../TableCellWrapper'; import type { OperatorData, Props } from './types'; import VaultsDropdown from './VaultsDropdown'; diff --git a/apps/tangle-dapp/components/tables/Operators/types.ts b/apps/tangle-dapp/components/tables/Operators/types.ts index bb5f87a719..f5f1d9d1b9 100644 --- a/apps/tangle-dapp/components/tables/Operators/types.ts +++ b/apps/tangle-dapp/components/tables/Operators/types.ts @@ -1,7 +1,7 @@ import type { Table } from '@webb-tools/webb-ui-components/components/Table'; import type { ComponentProps } from 'react'; -import type { TableStatus } from '../../TableStatus'; +import TableStatus from '../../TableStatus'; export type VaultToken = { name: string; diff --git a/apps/tangle-dapp/components/tables/Vaults/index.tsx b/apps/tangle-dapp/components/tables/Vaults/index.tsx index f692ad37d0..05534c1939 100644 --- a/apps/tangle-dapp/components/tables/Vaults/index.tsx +++ b/apps/tangle-dapp/components/tables/Vaults/index.tsx @@ -22,8 +22,8 @@ import { twMerge } from 'tailwind-merge'; import { PagePath, QueryParamKey } from '../../../types'; import formatFractional from '../../../utils/formatFractional'; import getTVLToDisplay from '../../../utils/getTVLToDisplay'; -import LsTokenIcon from '../../LsTokenIcon'; -import { TableStatus } from '../../TableStatus'; +import LsTokenIcon from '../../LiquidStaking/LsTokenIcon'; +import TableStatus from '../../TableStatus'; import TableCellWrapper from '../TableCellWrapper'; import type { Props, VaultData } from './types'; diff --git a/apps/tangle-dapp/components/tables/Vaults/types.ts b/apps/tangle-dapp/components/tables/Vaults/types.ts index 2ff75ad3e2..9a88da4457 100644 --- a/apps/tangle-dapp/components/tables/Vaults/types.ts +++ b/apps/tangle-dapp/components/tables/Vaults/types.ts @@ -1,7 +1,7 @@ import type { Table } from '@webb-tools/webb-ui-components/components/Table'; import type { ComponentProps } from 'react'; -import type { TableStatus } from '../../TableStatus'; +import TableStatus from '../../TableStatus'; export type VaultData = { id: string; diff --git a/apps/tangle-dapp/constants/env.ts b/apps/tangle-dapp/constants/env.ts deleted file mode 100644 index 15783da71f..0000000000 --- a/apps/tangle-dapp/constants/env.ts +++ /dev/null @@ -1 +0,0 @@ -export const IS_PRODUCTION_ENV = process.env.NODE_ENV === 'production'; diff --git a/apps/tangle-dapp/constants/index.ts b/apps/tangle-dapp/constants/index.ts index f89a686455..c9cee6ed71 100644 --- a/apps/tangle-dapp/constants/index.ts +++ b/apps/tangle-dapp/constants/index.ts @@ -3,6 +3,8 @@ import { StakingRewardsDestinationDisplayText, } from '../types'; +export const IS_PRODUCTION_ENV = process.env.NODE_ENV === 'production'; + /** * The lock ids are always 8 characters long, due to their representation * as a `U8aFixed` in the Substrate runtime. That is why the enum values diff --git a/apps/tangle-dapp/constants/evmPrecompiles.ts b/apps/tangle-dapp/constants/precompiles.ts similarity index 100% rename from apps/tangle-dapp/constants/evmPrecompiles.ts rename to apps/tangle-dapp/constants/precompiles.ts diff --git a/apps/tangle-dapp/containers/BondMoreTxContainer/index.ts b/apps/tangle-dapp/containers/BondMoreTxContainer/index.ts deleted file mode 100644 index 0ad4d67a72..0000000000 --- a/apps/tangle-dapp/containers/BondMoreTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as BondMoreTxContainer } from './BondMoreTxContainer'; diff --git a/apps/tangle-dapp/containers/BondMoreTxContainer/types.ts b/apps/tangle-dapp/containers/BondMoreTxContainer/types.ts deleted file mode 100644 index e9305c5224..0000000000 --- a/apps/tangle-dapp/containers/BondMoreTxContainer/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type BondMoreTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; - -export type BondTokensProps = { - amountToBond: number; - setAmountToBond: (amount: number) => void; - amountToBondError?: string; - amountWalletBalance: number; -}; diff --git a/apps/tangle-dapp/containers/DebugMetricsContainer/DebugMetrics.tsx b/apps/tangle-dapp/containers/DebugMetrics.tsx similarity index 98% rename from apps/tangle-dapp/containers/DebugMetricsContainer/DebugMetrics.tsx rename to apps/tangle-dapp/containers/DebugMetrics.tsx index 9944c7b438..bc32fbb776 100644 --- a/apps/tangle-dapp/containers/DebugMetricsContainer/DebugMetrics.tsx +++ b/apps/tangle-dapp/containers/DebugMetrics.tsx @@ -10,7 +10,7 @@ import { import { SkeletonLoader, Typography } from '@webb-tools/webb-ui-components'; import { FC, useCallback, useEffect, useState } from 'react'; -import useDebugMetricsStore from '../../context/useDebugMetricsStore'; +import useDebugMetricsStore from '../context/useDebugMetricsStore'; /** * Format bytes to megabytes, rounded to two decimal places diff --git a/apps/tangle-dapp/containers/DebugMetricsContainer/index.ts b/apps/tangle-dapp/containers/DebugMetricsContainer/index.ts deleted file mode 100644 index 8405ad051a..0000000000 --- a/apps/tangle-dapp/containers/DebugMetricsContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './DebugMetrics'; diff --git a/apps/tangle-dapp/containers/DelegateTxContainer/index.ts b/apps/tangle-dapp/containers/DelegateTxContainer/index.ts deleted file mode 100644 index 30effdcdb2..0000000000 --- a/apps/tangle-dapp/containers/DelegateTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as DelegateTxContainer } from './DelegateTxContainer'; diff --git a/apps/tangle-dapp/containers/HeaderChipsContainer/HeaderChipsContainer.tsx b/apps/tangle-dapp/containers/HeaderChipsContainer.tsx similarity index 87% rename from apps/tangle-dapp/containers/HeaderChipsContainer/HeaderChipsContainer.tsx rename to apps/tangle-dapp/containers/HeaderChipsContainer.tsx index 99f5b0dd87..d8f94fa23f 100644 --- a/apps/tangle-dapp/containers/HeaderChipsContainer/HeaderChipsContainer.tsx +++ b/apps/tangle-dapp/containers/HeaderChipsContainer.tsx @@ -1,6 +1,6 @@ import { BlockIcon } from '@webb-tools/icons'; -import { HeaderChip } from '../../components'; +import { HeaderChip } from '../components'; const HeaderChipsContainer = () => { return ( diff --git a/apps/tangle-dapp/containers/HeaderChipsContainer/index.ts b/apps/tangle-dapp/containers/HeaderChipsContainer/index.ts deleted file mode 100644 index c79d6dc781..0000000000 --- a/apps/tangle-dapp/containers/HeaderChipsContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as HeaderChipsContainer } from './HeaderChipsContainer'; diff --git a/apps/tangle-dapp/containers/Layout/Layout.tsx b/apps/tangle-dapp/containers/Layout.tsx similarity index 85% rename from apps/tangle-dapp/containers/Layout/Layout.tsx rename to apps/tangle-dapp/containers/Layout.tsx index 1d0f7d9d28..8c7f30ccd9 100644 --- a/apps/tangle-dapp/containers/Layout/Layout.tsx +++ b/apps/tangle-dapp/containers/Layout.tsx @@ -11,14 +11,10 @@ import { import { useLayoutBgClassName } from '@webb-tools/webb-ui-components/next-utils'; import { type FC, type PropsWithChildren } from 'react'; -import { - BridgeTxQueueDropdown, - MobileSidebar, - Sidebar, -} from '../../components'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; -import ApiDevStatsContainer from '../DebugMetricsContainer'; -import WalletAndChainContainer from '../WalletAndChainContainer/WalletAndChainContainer'; +import { BridgeTxQueueDropdown, MobileSidebar, Sidebar } from '../components'; +import { IS_PRODUCTION_ENV } from '../constants/env'; +import DebugMetrics from './DebugMetrics'; +import WalletAndChainContainer from './WalletAndChainContainer'; // Some specific overrides for the social links for use in the // footer in Tangle dApp, since it defaults to the Webb socials. @@ -74,7 +70,7 @@ const Layout: FC> = ({ - {!IS_PRODUCTION_ENV && } + {!IS_PRODUCTION_ENV && } ); }; diff --git a/apps/tangle-dapp/containers/Layout/index.ts b/apps/tangle-dapp/containers/Layout/index.ts deleted file mode 100644 index 6c48faec7d..0000000000 --- a/apps/tangle-dapp/containers/Layout/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Layout } from './Layout'; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationChart.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationChart.tsx deleted file mode 100644 index 4ff0cd8615..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationChart.tsx +++ /dev/null @@ -1,175 +0,0 @@ -import { BN, BN_ZERO } from '@polkadot/util'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { Typography, useNextDarkMode } from '@webb-tools/webb-ui-components'; -import { FC } from 'react'; -import { - Cell, - Pie, - PieChart, - PieProps, - RadialBar, - RadialBarChart, - ResponsiveContainer, - Tooltip as RechartsTooltip, -} from 'recharts'; - -import BnChartTooltip from '../../components/BnChartTooltip'; -import { ChartColor } from '../../constants'; -import { RestakingService } from '../../types'; -import { getChartDataAreaColorByServiceType } from '../../utils'; -import formatTangleBalance from '../../utils/formatTangleBalance'; -import { RestakingAllocationMap } from './types'; -import useAllocationChartEntries, { - AllocationChartEntryName, -} from './useAllocationChartEntries'; - -export enum AllocationChartVariant { - INDEPENDENT, - SHARED, -} - -export type AllocationChartProps = { - variant: AllocationChartVariant; - allocations: RestakingAllocationMap; - allocatedAmount: BN; - previewAmount?: BN; - previewRole?: RestakingService; -}; - -function getChartColorOfEntryName( - entryName: AllocationChartEntryName, -): ChartColor { - switch (entryName) { - case 'Remaining': - return ChartColor.DARK_GRAY; - case 'New Allocation': - return ChartColor.LAVENDER; - default: - return getChartDataAreaColorByServiceType(entryName); - } -} - -const AllocationChart: FC = ({ - allocatedAmount, - allocations, - variant, - previewAmount, - previewRole, -}) => { - const [isDarkMode] = useNextDarkMode(); - const { nativeTokenSymbol } = useNetworkStore(); - - const { allocationEntries, entries } = useAllocationChartEntries( - allocations, - allocatedAmount, - variant, - ); - - const themeCellColor: ChartColor = isDarkMode - ? ChartColor.DARK_GRAY - : ChartColor.GRAY; - - const tooltip = ( - - ); - - const cellColors = ( - <> - {(variant === AllocationChartVariant.INDEPENDENT || - allocationEntries.length === 0) && ( - - )} - - {variant === AllocationChartVariant.INDEPENDENT && - previewAmount !== undefined && - !previewAmount.isZero() && ( - - )} - - {allocationEntries.map((entry) => ( - - ))} - - ); - - const sharedChartProps = { - // TODO: Something's causing a duplicate key prop error within the Pie component. Need to investigate what it is (`sector-333-333`). - data: entries, - stroke: 'none', - dataKey: 'value', - } satisfies PieProps; - - return ( -
-
- - {variant === AllocationChartVariant.INDEPENDENT ? ( - - - {cellColors} - - - {tooltip} - - ) : ( - - - {cellColors} - - - {tooltip} - - )} - -
- -
- - Restaked - - - - {formatTangleBalance(allocatedAmount)} - - - - {nativeTokenSymbol} - -
-
- ); -}; - -export default AllocationChart; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStep.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStep.tsx deleted file mode 100644 index d12a8ce04a..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStep.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { BN } from '@polkadot/util'; -import { Dispatch, FC, SetStateAction } from 'react'; - -import { RestakingProfileType } from '../../types'; -import ChooseMethodStep from './ChooseMethodStep'; -import ConfirmAllocationsStep from './ConfirmAllocationsStep'; -import IndependentAllocationStep from './Independent/IndependentAllocationStep'; -import { ManageProfileStep } from './ManageProfileModalContainer'; -import SharedAllocationStep from './Shared/SharedAllocationStep'; -import { RestakingAllocationMap } from './types'; - -export type AllocationStepProps = { - allocations: RestakingAllocationMap; - step: ManageProfileStep; - profileType: RestakingProfileType; - sharedRestakeAmount: BN | null; - setSharedRestakeAmount: Dispatch>; - setAllocations: (newAllocations: RestakingAllocationMap) => void; - setAllocationsDispatch: Dispatch>; - setProfileType: (newProfileType: RestakingProfileType) => void; -}; - -const AllocationStep: FC = ({ - step, - profileType, - allocations, - sharedRestakeAmount, - setSharedRestakeAmount, - setAllocations, - setAllocationsDispatch, - setProfileType, -}) => { - switch (step) { - case ManageProfileStep.CHOOSE_METHOD: - return ( - - ); - case ManageProfileStep.ALLOCATION: - return profileType === RestakingProfileType.INDEPENDENT ? ( - - ) : ( - - ); - case ManageProfileStep.CONFIRM_ALLOCATIONS: - return ( - - ); - } -}; - -export default AllocationStep; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStepContainer.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStepContainer.tsx deleted file mode 100644 index ddc400f13b..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/AllocationStepContainer.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React, { FC, ReactNode } from 'react'; - -import AllocationChart, { AllocationChartProps } from './AllocationChart'; - -export interface AllocationStepContainerProps extends AllocationChartProps { - children: ReactNode; -} - -const AllocationStepContainer: FC = ({ - children, - ...allocationChartProps -}) => { - return ( -
-
- {children} -
- -
- -
-
- ); -}; - -export default AllocationStepContainer; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/ChooseMethodStep.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/ChooseMethodStep.tsx deleted file mode 100644 index c03c481e29..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/ChooseMethodStep.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { - Card, - Typography, - useNextDarkMode, -} from '@webb-tools/webb-ui-components'; -import Image from 'next/image'; -import { FC, ReactNode } from 'react'; -import { twMerge } from 'tailwind-merge'; - -import { StaticAssetPath } from '../../constants/index'; -import { RestakingProfileType } from '../../types'; - -export type ChooseMethodStepProps = { - profileType: RestakingProfileType; - setProfileType: (profileType: RestakingProfileType) => void; -}; - -const IMAGE_SIZE = 120; - -const ChooseMethodStep: FC = ({ - profileType, - setProfileType, -}) => { - const [isDarkMode] = useNextDarkMode(); - - return ( -
- - Independent restaking method illustration - - - Independent - - - - Allocate variable amounts to each role independently. - - - - - Shared restaking method illustration - - - Shared - - - - Allocate a single amount to be shared between selected roles. - - -
- ); -}; - -type OptionCardProps = { - profileType: RestakingProfileType; - selectedProfileType: RestakingProfileType; - children: ReactNode; - setSelected: (profileType: RestakingProfileType) => void; -}; - -/** @internal */ -const OptionCard: FC = ({ - profileType, - selectedProfileType, - children, - setSelected, -}) => { - const isSelected = selectedProfileType === profileType; - - const isSelectedClassName = isSelected - ? 'border-mono-60 dark:border-mono-140' - : 'border-transparent cursor-pointer'; - - return ( - setSelected(profileType)} - className={twMerge( - 'flex justify-center items-center gap-1 space-y-0 border-[3px] rounded-2xl bg-mono-20 dark:bg-mono-160', - isSelectedClassName, - )} - > - {children} - - ); -}; - -export default ChooseMethodStep; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/ConfirmAllocationsStep.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/ConfirmAllocationsStep.tsx deleted file mode 100644 index 732c2cfed1..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/ConfirmAllocationsStep.tsx +++ /dev/null @@ -1,222 +0,0 @@ -import { BN, BN_ZERO } from '@polkadot/util'; -import { InformationLine } from '@webb-tools/icons'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { TangleTokenSymbol } from '@webb-tools/tangle-shared-ui/types'; -import { Chip, Typography } from '@webb-tools/webb-ui-components'; -import assert from 'assert'; -import { FC } from 'react'; -import { twMerge } from 'tailwind-merge'; - -import { RestakingProfileType, RestakingService } from '../../types'; -import { getChipColorOfServiceType } from '../../utils'; -import formatTangleBalance from '../../utils/formatTangleBalance'; -import { filterAllocations } from './Independent/IndependentAllocationStep'; -import { RestakingAllocationMap } from './types'; - -export type ConfirmAllocationsStepProps = { - profileType: RestakingProfileType; - allocations: RestakingAllocationMap; - sharedRestakeAmount?: BN; -}; - -const ConfirmAllocationsStep: FC = ({ - profileType, - allocations, - sharedRestakeAmount, -}) => { - const { nativeTokenSymbol } = useNetworkStore(); - - const isSharedVariant = profileType === RestakingProfileType.SHARED; - - if (isSharedVariant) { - assert( - sharedRestakeAmount !== undefined, - 'Shared restake amount should be defined for the shared profile type (did you forget to pass the shared restake amount prop?)', - ); - } - - const restakedAmount = filterAllocations(allocations).reduce( - (acc, [, amount]) => acc.add(amount), - BN_ZERO, - ); - - const filteredAllocations = filterAllocations(allocations); - - const cardBaseClassName = - 'flex flex-col gap-2 bg-mono-20 dark:bg-mono-160 rounded-lg w-full p-4 border border-mono-40 dark:border-mono-140'; - - // Give priority to the shared restaked amount, if provided. - // This is because the shared restake amount is not automatically - // calculated from the allocations, since shared roles profiles - // do not allocate amounts per-role, but rather as a whole. - const totalRestakedAmount = formatTangleBalance( - isSharedVariant && sharedRestakeAmount !== undefined - ? sharedRestakeAmount - : restakedAmount, - nativeTokenSymbol, - ); - - return ( -
-
-
- - Profile Type - - - - {profileType === RestakingProfileType.INDEPENDENT - ? 'Independent' - : 'Shared'} - -
- -
- {isSharedVariant - ? filteredAllocations.length > 0 && ( - service, - )} - tokenSymbol={nativeTokenSymbol} - /> - ) - : filteredAllocations.map(([service, amount]) => ( - - ))} - - {filteredAllocations.length === 0 && ( - - No allocations - - )} -
- -
- - Total Restake Amount - - - - {totalRestakedAmount} - -
-
- -
-
- - Things to Note - - - -
- -
- - Active Service Lock-In: - - -
    -
  • - - Restaked tokens in active roles are locked for the duration of - the service. Active roles can only have increased restakes. - -
  • -
-
- -
- - Switching to Shared Profile: - - -
    -
  • - - Shared profile requires even distribution of total restake - across all roles. Total shared restake must be at least equal to - current total for active roles. - -
  • -
-
-
-
- ); -}; - -type AllocationItemProps = { - services: RestakingService[]; - amount?: BN; - tokenSymbol: TangleTokenSymbol; -}; - -/** @internal */ -const AllocationItem: FC = ({ - services, - amount, - tokenSymbol, -}) => { - return ( -
-
- {services.map((service) => ( - - {service} - - ))} -
- - {amount !== undefined && ( - - {formatTangleBalance(amount, tokenSymbol)} - - )} -
- ); -}; - -export default ConfirmAllocationsStep; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationInput.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationInput.tsx deleted file mode 100644 index e160aeab7f..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationInput.tsx +++ /dev/null @@ -1,184 +0,0 @@ -import { BN } from '@polkadot/util'; -import { TANGLE_TOKEN_DECIMALS } from '@webb-tools/dapp-config/constants/tangle'; -import { Close, LockLineIcon } from '@webb-tools/icons'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { Chip, Input, SkeletonLoader } from '@webb-tools/webb-ui-components'; -import { FC, useCallback, useMemo, useState } from 'react'; - -import InputWrapper from '../../../components/InputWrapper'; -import useInputAmount from '../../../hooks/useInputAmount'; -import { RestakingService } from '../../../types'; -import { getChipColorOfServiceType } from '../../../utils'; -import formatTangleBalance from '../../../utils/formatTangleBalance'; -import InputAction from '../InputAction'; - -export type IndependentAllocationInputProps = { - amount: BN | null; - setAmount: (newAmount: BN | null) => void; - availableServices: RestakingService[]; - availableBalance: BN | null; - service: RestakingService | null; - id: string; - validate?: boolean; - errorOnEmptyValue?: boolean; - onDelete?: (service: RestakingService) => void; - setService?: (service: RestakingService) => void; -}; - -export const ERROR_MIN_RESTAKING_BOND = - 'Must be at least the minimum restaking bond'; - -export const ERROR_NOT_ENOUGH_BALANCE = 'Not enough available balance'; - -/** - * A specialized input used to allocate roles for creating or - * updating job profiles in Substrate. - */ -const IndependentAllocationInput: FC = ({ - amount = null, - setAmount, - availableBalance, - availableServices, - validate = true, - id, - service, - setService, - onDelete, - errorOnEmptyValue = true, -}) => { - const { nativeTokenSymbol } = useNetworkStore(); - - // TODO: This is misleading, because it defaults to `false` when `servicesWithJobs` is still loading. It needs to default to `null` and have its loading state handled appropriately. - const hasActiveJob = false; - - const substrateAllocationAmount = null; - const min = substrateAllocationAmount; - - const [isDropdownVisible, setIsDropdownVisible] = useState(false); - - const minErrorMessage = hasActiveJob - ? 'Cannot decrease restake amount for an active role' - : ERROR_MIN_RESTAKING_BOND; - - const { - displayAmount: amountString, - errorMessage, - handleChange, - } = useInputAmount({ - amount, - min, - max: availableBalance, - decimals: TANGLE_TOKEN_DECIMALS, - errorOnEmptyValue, - setAmount, - minErrorMessage, - maxErrorMessage: ERROR_NOT_ENOUGH_BALANCE, - }); - - const handleDelete = useCallback(() => { - if (onDelete !== undefined && service !== null) { - onDelete(service); - } - }, [onDelete, service]); - - const handleSetService = useCallback( - (service: RestakingService) => { - if (setService === undefined) { - return; - } - - setService(service); - setIsDropdownVisible(false); - }, - [setService], - ); - - const dropdownBody = useMemo( - () => - availableServices - .filter((availableRole) => availableRole !== service) - // Sort roles in ascending order, by their display - // values (strings). This is done with the intent to - // give priority to the TSS roles. - .toSorted((a, b) => a.localeCompare(b)) - .map((service) => ( -
handleSetService(service)} - className="flex justify-between p-2 rounded-lg cursor-pointer hover:bg-mono-20 dark:hover:bg-mono-160" - > - {service} - - {min !== null ? ( - - {`≥ ${formatTangleBalance(min)}`} - - ) : ( - - )} -
- )), - [availableServices, handleSetService, min, service], - ); - - // Users can remove roles only if there are no active services - // linked to those roles. - const canBeDeleted = !hasActiveJob && onDelete !== undefined; - - const actions = ( - <> - {hasActiveJob && ( - - )} - - {canBeDeleted && ( - - )} - - ); - - const hasDropdownBody = !hasActiveJob && setService !== undefined; - - return ( - - - - ); -}; - -export default IndependentAllocationInput; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationStep.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationStep.tsx deleted file mode 100644 index 475e34fc9f..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Independent/IndependentAllocationStep.tsx +++ /dev/null @@ -1,202 +0,0 @@ -import { BN, BN_ZERO } from '@polkadot/util'; -import { Button, Typography } from '@webb-tools/webb-ui-components'; -import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; -import assert from 'assert'; -import { - Dispatch, - FC, - SetStateAction, - useCallback, - useMemo, - useState, -} from 'react'; -import { z } from 'zod'; - -import { RestakingService } from '../../../types'; -import { AllocationChartVariant } from '../AllocationChart'; -import AllocationStepContainer from '../AllocationStepContainer'; -import { RestakingAllocationMap } from '../types'; -import IndependentAllocationInput from './IndependentAllocationInput'; - -export type IndependentAllocationStepProps = { - allocations: RestakingAllocationMap; - setAllocations: Dispatch>; -}; - -export function filterAllocations( - allocations: RestakingAllocationMap, -): [RestakingService, BN][] { - return Object.entries(allocations).map(([serviceString, amount]) => { - const service = z.nativeEnum(RestakingService).parse(serviceString); - - return [service, amount]; - }); -} - -const IndependentAllocationStep: FC = ({ - allocations, - setAllocations, -}) => { - const restakedAmount = useMemo( - () => - Object.entries(allocations).reduce( - (acc, [_key, amount]) => acc.add(amount), - BN_ZERO, - ), - [allocations], - ); - - const [newAllocationAmount, setNewAllocationAmount] = useState( - null, - ); - - const [newAllocationRole, setNewAllocationRole] = - useState(null); - - const handleNewAllocation = useCallback(() => { - if (newAllocationRole === null || newAllocationAmount === null) { - return; - } - - setAllocations((prev) => ({ - ...prev, - [newAllocationRole]: newAllocationAmount, - })); - - setNewAllocationRole(null); - setNewAllocationAmount(null); - }, [ - newAllocationAmount, - newAllocationRole, - setAllocations, - setNewAllocationAmount, - ]); - - const handleDeallocation = useCallback( - (service: RestakingService) => { - const deallocatedAmount = allocations[service]; - - assert( - deallocatedAmount !== undefined, - 'Allocations should have an entry for the service being deallocated', - ); - - setAllocations((prev) => { - const nextAllocations = Object.assign({}, prev); - - delete nextAllocations[service]; - - return nextAllocations; - }); - }, - [allocations, setAllocations], - ); - - const handleAllocationChange = useCallback( - (service: RestakingService, newAmount: BN | null) => { - // Do not update the amount if it has no value, - // or if the new amount is the same as the current amount. - if (newAmount === null || allocations[service]?.eq(newAmount)) { - return; - } - - setAllocations((prev) => ({ - ...prev, - [service]: newAmount, - })); - }, - [allocations, setAllocations], - ); - - const isNewAllocationAmountValid = (() => { - if ( - newAllocationRole === null || - newAllocationAmount === null || - newAllocationAmount.isZero() - ) { - return false; - } - - return true; - })(); - - const availableRoles = useMemo( - () => - Object.values(RestakingService).filter( - (service) => !(service in allocations), - ), - [allocations], - ); - - const filteredAllocations = useMemo( - () => filterAllocations(allocations), - [allocations], - ); - - const canAddNewAllocation = availableRoles.length > 0; - - return ( - -
-
- {filteredAllocations.map(([service, amount]) => ( - - handleAllocationChange(service, newAmount) - } - onDelete={handleDeallocation} - availableBalance={null} - errorOnEmptyValue - /> - ))} - - {canAddNewAllocation && ( - - )} -
- -
- - Remaining: {EMPTY_VALUE_PLACEHOLDER} - - -
- {availableRoles.length > 0 && ( - - )} -
-
-
-
- ); -}; - -export default IndependentAllocationStep; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/ManageProfileModalContainer.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/ManageProfileModalContainer.tsx deleted file mode 100644 index 120e26eb86..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/ManageProfileModalContainer.tsx +++ /dev/null @@ -1,289 +0,0 @@ -import { - Button, - Modal, - ModalBody, - ModalContent, - ModalFooter, - ModalHeader, - Typography, -} from '@webb-tools/webb-ui-components'; -import useIsMountedRef from '@webb-tools/webb-ui-components/hooks/useIsMountedRef'; -import assert from 'assert'; -import { FC, useCallback, useEffect, useState } from 'react'; - -import { useErrorCountContext } from '../../context/ErrorsContext'; -import { RestakingProfileType } from '../../types'; -import AllocationStep from './AllocationStep'; -import useSharedRestakeAmountState from './Shared/useSharedRestakeAmountState'; -import { ManageProfileModalContainerProps } from './types'; -import useAllocationsState from './useAllocationsState'; - -/** - * The steps in the manage profile modal. - * - * @remarks - * The order of the steps is important, as it determines - * the flow of the modal. - */ -export enum ManageProfileStep { - CHOOSE_METHOD, - ALLOCATION, - CONFIRM_ALLOCATIONS, -} - -function getStepDiff( - currentStep: ManageProfileStep, - isNext: boolean, -): ManageProfileStep | null { - const difference = isNext ? 1 : -1; - - if (Object.values(ManageProfileStep).includes(currentStep + difference)) { - return currentStep + difference; - } - - return null; -} - -function getStepTitle( - step: ManageProfileStep, - profileType: RestakingProfileType, - isCreatingProfile: boolean, -): string { - switch (step) { - case ManageProfileStep.CHOOSE_METHOD: - return 'Choose Your Restaking Method'; - case ManageProfileStep.ALLOCATION: { - const profileKindString = - profileType === RestakingProfileType.INDEPENDENT - ? 'Independent' - : 'Shared'; - - const actionPrefix = isCreatingProfile ? 'Create' : 'Manage'; - - return `${actionPrefix} ${profileKindString} Profile`; - } - case ManageProfileStep.CONFIRM_ALLOCATIONS: - return 'Review and Confirm Your Allocations:'; - } -} - -function getStepNextButtonLabel(step: ManageProfileStep): string { - switch (step) { - case ManageProfileStep.CHOOSE_METHOD: - return 'Next'; - case ManageProfileStep.ALLOCATION: - return 'Review Changes'; - case ManageProfileStep.CONFIRM_ALLOCATIONS: - return 'Confirm'; - } -} - -function getStepPreviousButtonLabel(step: ManageProfileStep): string { - switch (step) { - case ManageProfileStep.CHOOSE_METHOD: - return "What's the Difference?"; - case ManageProfileStep.ALLOCATION: - return 'Back'; - case ManageProfileStep.CONFIRM_ALLOCATIONS: - return 'Go Back and Edit'; - } -} - -function getStepDescription( - step: ManageProfileStep, - profileType: RestakingProfileType, - isCreatingProfile: boolean, -): string | null { - switch (step) { - case ManageProfileStep.CHOOSE_METHOD: - return 'To participate in MPC services, allocate your staked TNT tokens using one of the available restaking methods. Your choice determines your risk allocation strategy. Would you like to restake as independent or shared?'; - case ManageProfileStep.ALLOCATION: - return isCreatingProfile - ? profileType === RestakingProfileType.INDEPENDENT - ? 'Independent restaking allows you to allocate specific amounts of your stake to individual roles. Active roles may have their stake increased. Inactive roles are flexible for both stake adjustments and removal.' - : 'Shared restaking allows your entire restake to be allocated across selected roles, amplifying your participation. You can increase the total stake but cannot reduce it until every active service ends. Role removal is possible only if they are inactive.' - : profileType === RestakingProfileType.INDEPENDENT - ? 'Independent restaking allows you to allocate specific amounts of your stake to individual roles. Active roles may have their stake increased. Inactive roles are flexible for both stake adjustments and removal.' - : 'Shared restaking allows your entire restake to be allocated across selected roles, amplifying your participation. You can increase the total stake but cannot reduce it until every active service ends. Role removal is possible only if they are inactive.'; - case ManageProfileStep.CONFIRM_ALLOCATIONS: - return null; - } -} - -const ManageProfileModalContainer: FC = ({ - hasExistingProfile, - isModalOpen, - profileTypeOpt, - setIsModalOpen, -}) => { - const [profileType, setProfileType] = useState( - RestakingProfileType.INDEPENDENT, - ); - - const { - sharedRestakeAmount, - setSharedRestakeAmount, - isLoading: isLoadingSharedRestakeAmount, - resetToSubstrateAmount: resetSharedRestakeAmount, - } = useSharedRestakeAmountState(); - - const [step, setStep] = useState(ManageProfileStep.CHOOSE_METHOD); - const isMountedRef = useIsMountedRef(); - - const { - allocations, - setAllocations, - setAllocationsDispatch, - isLoading: isLoadingAllocations, - reset: resetAllocations, - } = useAllocationsState(profileType); - - const handlePreviousStep = useCallback(() => { - const diff = getStepDiff(step, false); - const previousStep = diff ?? ManageProfileStep.CHOOSE_METHOD; - - if (previousStep === ManageProfileStep.CHOOSE_METHOD) { - resetAllocations(); - } - - setStep(previousStep); - }, [resetAllocations, step]); - - const handleNextStep = useCallback(() => { - const nextStep = getStepDiff(step, true); - - if (nextStep !== null) { - setStep(nextStep); - - return; - } - - // Have reached the end; submit the transaction. - if (profileType === RestakingProfileType.INDEPENDENT) { - return; - } else { - assert( - sharedRestakeAmount !== null, - 'Shared restake amount should be set if updating shared profile', - ); - } - }, [profileType, sharedRestakeAmount, step]); - - const resetAllocationState = useCallback(() => { - resetAllocations(); - resetSharedRestakeAmount(); - }, [resetAllocations, resetSharedRestakeAmount]); - - const { errors, clearErrors } = useErrorCountContext(); - - // Reset allocations when the selected profile type changes. - // This is necessary because the allocations are specific to - // the profile type, and if the user switches between the - // independent and shared profile types, the allocations - // should be reset to an empty object. - useEffect(() => { - resetAllocationState(); - }, [profileType, resetAllocationState]); - - // Clear errors when the user changes the step - // to the "choose method" step, which essentially - // resets the state of the modal. - useEffect(() => { - if (step === ManageProfileStep.CHOOSE_METHOD) { - clearErrors(); - } - }, [clearErrors, step]); - - // Reset state when modal is closed. - useEffect(() => { - if (isModalOpen) { - return; - } - - // Use a timeout to prevent the state reset from being visible - // to the user as the modal is closing (the closing animation takes - // a few hundred milliseconds to complete). - const timeoutHandle = setTimeout(() => { - if (isMountedRef.current) { - setProfileType(RestakingProfileType.INDEPENDENT); - setStep(ManageProfileStep.CHOOSE_METHOD); - resetAllocationState(); - } - }, 500); - - return () => clearTimeout(timeoutHandle); - }, [isModalOpen, isMountedRef, resetAllocations, resetAllocationState]); - - // TODO: This will be `false` if it's still loading. It'll default to `true`, but hat's fine for now since it's used to show text/copy in the UI. Ideally would want a loading state to show the user, before showing everything else in this component. - const isCreatingProfile = - hasExistingProfile === false || profileTypeOpt?.value !== profileType; - - const stepDescription = getStepDescription( - step, - profileType, - isCreatingProfile, - ); - - const isLoading = - isLoadingSharedRestakeAmount || - isLoadingAllocations || - hasExistingProfile === null; - - const canContinue = - step === ManageProfileStep.CHOOSE_METHOD || - (!isLoading && errors.size === 0); - - return ( - - setIsModalOpen(false)} - isOpen={isModalOpen} - size="lg" - > - setIsModalOpen(false)}> - {getStepTitle(step, profileType, isCreatingProfile)} - - - - {stepDescription !== null && ( - - {stepDescription} - - )} - - - - - - - - - - - - ); -}; - -export default ManageProfileModalContainer; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAllocationStep.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAllocationStep.tsx deleted file mode 100644 index ba6128d889..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAllocationStep.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { BN, BN_ZERO } from '@polkadot/util'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { Typography } from '@webb-tools/webb-ui-components'; -import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; -import { FC, useCallback, useEffect, useState } from 'react'; - -import { RestakingService } from '../../../types'; -import formatTangleBalance from '../../../utils/formatTangleBalance'; -import { AllocationChartVariant } from '../AllocationChart'; -import AllocationStepContainer from '../AllocationStepContainer'; -import { RestakingAllocationMap } from '../types'; -import SharedAmountInput from './SharedAmountInput'; -import SharedRolesInput from './SharedRolesInput'; - -export type SharedAllocationStepProps = { - restakeAmount: BN | null; - setRestakeAmount: (newAmount: BN | null) => void; - allocations: RestakingAllocationMap; - setAllocations: (newAllocations: RestakingAllocationMap) => void; -}; - -const SharedAllocationStep: FC = ({ - allocations, - setAllocations, - restakeAmount, - setRestakeAmount, -}) => { - const { nativeTokenSymbol } = useNetworkStore(); - - const remainingAmount = null; - - const [selectedRoles, setSelectedRoles] = useState( - Object.keys(allocations) as RestakingService[], - ); - - const handleToggleRole = useCallback( - (role: RestakingService) => { - const isSelected = selectedRoles.includes(role); - - if (isSelected) { - setSelectedRoles((roles) => - roles.filter((selectedRole) => selectedRole !== role), - ); - } else { - setSelectedRoles((roles) => [...roles, role]); - } - }, - [selectedRoles], - ); - - // Update allocations when the selected roles changes. - useEffect(() => { - const nextAllocations: RestakingAllocationMap = {}; - - // Shared roles profile allocations have their amounts - // set to zero. - for (const selectedRole of selectedRoles) { - nextAllocations[selectedRole] = BN_ZERO; - } - - setAllocations(nextAllocations); - }, [selectedRoles, setAllocations]); - - return ( - - - - - - - Remaining:{' '} - {remainingAmount !== null - ? formatTangleBalance(remainingAmount, nativeTokenSymbol) - : EMPTY_VALUE_PLACEHOLDER} - - - ); -}; - -export default SharedAllocationStep; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAmountInput.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAmountInput.tsx deleted file mode 100644 index f1f7bf4bea..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedAmountInput.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { BN } from '@polkadot/util'; -import { TANGLE_TOKEN_DECIMALS } from '@webb-tools/dapp-config/constants/tangle'; -import useNetworkStore from '@webb-tools/tangle-shared-ui/context/useNetworkStore'; -import { Button, Input } from '@webb-tools/webb-ui-components'; -import { FC, useRef } from 'react'; - -import InputWrapper from '../../../components/InputWrapper'; -import useInputAmount from '../../../hooks/useInputAmount'; -import { - ERROR_MIN_RESTAKING_BOND, - ERROR_NOT_ENOUGH_BALANCE, -} from '../Independent/IndependentAllocationInput'; - -export type SharedAmountInputProps = { - id: string; - title: string; - amount: BN; - setAmount: (newAmount: BN | null) => void; -}; - -const SharedAmountInput: FC = ({ - id, - title, - amount, - setAmount, -}) => { - const { nativeTokenSymbol } = useNetworkStore(); - - const hasActiveJobsForSharedProfile = (() => { - return false; - })(); - - const minErrorMessage = hasActiveJobsForSharedProfile - ? 'Cannot decrease shared restake amount when there are active jobs' - : ERROR_MIN_RESTAKING_BOND; - - const { - displayAmount: amountString, - errorMessage, - handleChange, - } = useInputAmount({ - amount, - min: null, - max: null, - errorOnEmptyValue: true, - setAmount, - decimals: TANGLE_TOKEN_DECIMALS, - minErrorMessage, - maxErrorMessage: ERROR_NOT_ENOUGH_BALANCE, - }); - - const inputRef = useRef(null); - - const actions = [ - , - ]; - - return ( - - - - ); -}; - -export default SharedAmountInput; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedRolesInput.tsx b/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedRolesInput.tsx deleted file mode 100644 index 9aa9c9cd17..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/SharedRolesInput.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { Close } from '@webb-tools/icons'; -import { CheckBox, Chip, Typography } from '@webb-tools/webb-ui-components'; -import { FC, useCallback, useMemo, useState } from 'react'; -import { twMerge } from 'tailwind-merge'; - -import InputWrapper from '../../../components/InputWrapper'; -import { RestakingService } from '../../../types'; -import { - getChartDataAreaColorByServiceType, - getChipColorOfServiceType, -} from '../../../utils'; - -export type SharedRolesInputProps = { - title: string; - id: string; - selectedServices: RestakingService[]; - services: RestakingService[]; - onToggleRole: (role: RestakingService) => void; -}; - -const SharedRolesInput: FC = ({ - title, - id, - selectedServices, - services, - onToggleRole, -}) => { - const [isDropdownVisible, setIsDropdownVisible] = useState(false); - - const handleDeselectService = useCallback( - (service: RestakingService) => { - onToggleRole(service); - }, - [onToggleRole], - ); - - const handleSelectService = useCallback( - (service: RestakingService) => { - if (selectedServices.includes(service)) { - return; - } - - onToggleRole(service); - }, - [onToggleRole, selectedServices], - ); - - const determineIfLocked = useCallback( - (service: RestakingService): boolean => !selectedServices.includes(service), - [selectedServices], - ); - - const dropdownBody = useMemo( - () => - services - // Sort roles in ascending order, by their display - // values (strings). This is done with the intent to - // give priority to the TSS roles. - .toSorted((a, b) => a.localeCompare(b)) - .map((service) => { - const isLocked = determineIfLocked(service); - - return ( -
{ - if (selectedServices.includes(service)) { - handleDeselectService(service); - } else { - handleSelectService(service); - } - }} - className={twMerge( - 'flex items-center justify-between rounded-lg p-2 hover:bg-mono-20 dark:hover:bg-mono-160', - !isLocked ? 'cursor-pointer' : 'cursor-not-allowed', - )} - > -
- - -
- - - - {service} - -
-
-
- ); - }), - [ - services, - determineIfLocked, - selectedServices, - handleDeselectService, - handleSelectService, - ], - ); - - return ( - - {selectedServices.map((service) => { - const isLocked = determineIfLocked(service); - - return ( - handleDeselectService(service)} - > - {service} - - {!isLocked && } - - ); - })} - - {selectedServices.length === 0 && ( - setIsDropdownVisible(true)} - color="dark-grey" - className="cursor-pointer" - > - Select Role(s) - - )} - - ); -}; - -type DotProps = { - role: RestakingService; -}; - -/** @internal */ -const Dot: FC = ({ role }) => { - const color = getChartDataAreaColorByServiceType(role); - - return ( -
- ); -}; - -export default SharedRolesInput; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/useSharedRestakeAmountState.ts b/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/useSharedRestakeAmountState.ts deleted file mode 100644 index 22b7f91b4d..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/Shared/useSharedRestakeAmountState.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { BN } from '@polkadot/util'; -import noop from 'lodash/noop'; -import { useState } from 'react'; - -const useSharedRestakeAmountState = () => { - const [sharedRestakeAmountState, setSharedRestakeAmount] = - useState(null); - - return { - sharedRestakeAmount: sharedRestakeAmountState, - setSharedRestakeAmount, - isLoading: false, - resetToSubstrateAmount: noop, - }; -}; - -export default useSharedRestakeAmountState; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/index.ts b/apps/tangle-dapp/containers/ManageProfileModalContainer/index.ts deleted file mode 100644 index 08747b707f..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ManageProfileModalContainer'; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/types.ts b/apps/tangle-dapp/containers/ManageProfileModalContainer/types.ts deleted file mode 100644 index 0731c2757b..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BN } from '@polkadot/util'; -import Optional from '@webb-tools/tangle-shared-ui/utils/Optional'; - -import { RestakingProfileType } from '../../types'; -import { RestakingService } from '../../types'; - -export type ManageProfileModalContainerProps = { - hasExistingProfile: boolean | null; - profileTypeOpt: Optional | null; - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; - -export type RestakingAllocationMap = Partial>; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationChartEntries.ts b/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationChartEntries.ts deleted file mode 100644 index fd7f9d97f6..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationChartEntries.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { BN } from '@polkadot/util'; -import { useMemo } from 'react'; - -import { RestakingService } from '../../types'; -import { AllocationChartVariant } from './AllocationChart'; -import { filterAllocations } from './Independent/IndependentAllocationStep'; -import { RestakingAllocationMap } from './types'; - -export type AllocationChartEntryName = - | 'Remaining' - | 'New Allocation' - | RestakingService; - -export type AllocationChartEntry = { - name: AllocationChartEntryName; - value: number; -}; - -const useAllocationChartEntries = ( - allocations: RestakingAllocationMap, - _allocatedAmount: BN, - variant: AllocationChartVariant, -) => { - const previewEntry: AllocationChartEntry = useMemo(() => { - // Set value to 0 if the preview amount is not provided - // or if the max restaking amount is still loading. - const value = 0; - - return { - name: 'New Allocation', - value, - }; - }, []); - - const remainingEntry: AllocationChartEntry = useMemo(() => { - const previewPercentage = previewEntry?.value ?? 0; - - const percentage = previewPercentage; - - return { - name: 'Remaining', - value: 1 - percentage, - }; - }, [previewEntry?.value]); - - const allocationEntries: AllocationChartEntry[] = useMemo( - () => - filterAllocations(allocations).map(([service]) => ({ - name: service, - value: 0, - })), - [allocations], - ); - - // For the independent variant, use both the remaining data - // entry, and the allocations. For the shared variant, use - // either: If no allocations, show the remaining balance, - // otherwise use the allocations as data entries. - const entries: AllocationChartEntry[] = useMemo(() => { - if (variant === AllocationChartVariant.INDEPENDENT) { - // Do not include the preview as an entry if its value - // is 0, otherwise it will take up some 'ghost' space in - // because of the separation between chart sections. - const pre = - previewEntry.value === 0 - ? [remainingEntry] - : [remainingEntry, previewEntry]; - - return pre.concat(allocationEntries); - } - // The profile type is shared. - else { - // No allocations; show the remaining section. - if (allocationEntries.length === 0) { - return [ - { - name: 'Remaining', - // Ensure that the remaining entry never has a value of 0, - // otherwise Recharts will not show the bar. - value: remainingEntry.value > 0 ? remainingEntry.value : 1, - }, - ]; - } - - return allocationEntries.map(({ name }) => ({ - name, - // Use a value of `1` so that Recharts shows the bar. - // This value doesn't matter much, since shared profiles - // do not set their amounts per-role, but rather as a whole. - value: 1, - })); - } - }, [allocationEntries, previewEntry, remainingEntry, variant]); - - return { entries, allocationEntries }; -}; - -export default useAllocationChartEntries; diff --git a/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationsState.ts b/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationsState.ts deleted file mode 100644 index ff588b790f..0000000000 --- a/apps/tangle-dapp/containers/ManageProfileModalContainer/useAllocationsState.ts +++ /dev/null @@ -1,26 +0,0 @@ -import noop from 'lodash/noop'; -import { useCallback, useState } from 'react'; - -import { RestakingProfileType } from '../../types'; -import { RestakingAllocationMap } from './types'; - -const useAllocationsState = (_: RestakingProfileType) => { - const [allocations, setAllocations] = useState({}); - - const setAllocationsOverride = useCallback( - (newAllocations: RestakingAllocationMap) => { - setAllocations(newAllocations); - }, - [], - ); - - return { - reset: noop, - isLoading: false, - allocations, - setAllocations: setAllocationsOverride, - setAllocationsDispatch: setAllocations, - }; -}; - -export default useAllocationsState; diff --git a/apps/tangle-dapp/containers/NominationsPayoutsContainer/index.ts b/apps/tangle-dapp/containers/NominationsPayoutsContainer/index.ts deleted file mode 100644 index 5fbe1a0915..0000000000 --- a/apps/tangle-dapp/containers/NominationsPayoutsContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as NominationsPayoutsContainer } from './NominationsPayoutsContainer'; diff --git a/apps/tangle-dapp/containers/NominatorStatsContainer/index.ts b/apps/tangle-dapp/containers/NominatorStatsContainer/index.ts deleted file mode 100644 index 530efa62f4..0000000000 --- a/apps/tangle-dapp/containers/NominatorStatsContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as NominatorStatsContainer } from './NominatorStatsContainer'; diff --git a/apps/tangle-dapp/containers/PayoutAllTxContainer/index.ts b/apps/tangle-dapp/containers/PayoutAllTxContainer/index.ts deleted file mode 100644 index 39685639b7..0000000000 --- a/apps/tangle-dapp/containers/PayoutAllTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PayoutAllTxContainer } from './PayoutAllTxContainer'; diff --git a/apps/tangle-dapp/containers/PayoutAllTxContainer/types.ts b/apps/tangle-dapp/containers/PayoutAllTxContainer/types.ts deleted file mode 100644 index 51f8993c76..0000000000 --- a/apps/tangle-dapp/containers/PayoutAllTxContainer/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Payout } from '@webb-tools/tangle-shared-ui/types'; - -export type PayoutTxProps = { - validatorSubstrateAddress: string; - era: number; -}; - -export type PayoutAllTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; - validatorsAndEras: PayoutTxProps[]; - payouts: Payout[]; - onComplete: () => void; -}; diff --git a/apps/tangle-dapp/containers/PayoutTxContainer/index.ts b/apps/tangle-dapp/containers/PayoutTxContainer/index.ts deleted file mode 100644 index d84f3bab40..0000000000 --- a/apps/tangle-dapp/containers/PayoutTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PayoutTxContainer } from './PayoutTxContainer'; diff --git a/apps/tangle-dapp/containers/PayoutTxContainer/types.ts b/apps/tangle-dapp/containers/PayoutTxContainer/types.ts deleted file mode 100644 index 3d36afd2dc..0000000000 --- a/apps/tangle-dapp/containers/PayoutTxContainer/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Payout } from '@webb-tools/tangle-shared-ui/types'; - -export type PayoutTxProps = { - validatorAddress: string; - era: number; -}; - -export type PayoutTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; - payoutTxProps: PayoutTxProps; - payouts: Payout[]; -}; diff --git a/apps/tangle-dapp/containers/RebondTxContainer/index.ts b/apps/tangle-dapp/containers/RebondTxContainer/index.ts deleted file mode 100644 index 8910795ab2..0000000000 --- a/apps/tangle-dapp/containers/RebondTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as RebondTxContainer } from './RebondTxContainer'; diff --git a/apps/tangle-dapp/containers/RebondTxContainer/types.ts b/apps/tangle-dapp/containers/RebondTxContainer/types.ts deleted file mode 100644 index 837b80b930..0000000000 --- a/apps/tangle-dapp/containers/RebondTxContainer/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type RebondTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; - -export type RebondTokensProps = { - amountToRebond: number; - setAmountToRebond: (amount: number) => void; - amountToRebondError?: string; - remainingUnbondedTokensToRebond: number; - unbondedAmount: number; - unbondingAmount: number; -}; diff --git a/apps/tangle-dapp/containers/StopNominationTxContainer/index.ts b/apps/tangle-dapp/containers/StopNominationTxContainer/index.ts deleted file mode 100644 index 2b1a90393b..0000000000 --- a/apps/tangle-dapp/containers/StopNominationTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as StopNominationTxContainer } from './StopNominationTxContainer'; diff --git a/apps/tangle-dapp/containers/StopNominationTxContainer/types.ts b/apps/tangle-dapp/containers/StopNominationTxContainer/types.ts deleted file mode 100644 index 8e9463aa9b..0000000000 --- a/apps/tangle-dapp/containers/StopNominationTxContainer/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type StopNominationTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; diff --git a/apps/tangle-dapp/containers/TransferTxContainer/index.ts b/apps/tangle-dapp/containers/TransferTxContainer/index.ts deleted file mode 100644 index 0202c69fbc..0000000000 --- a/apps/tangle-dapp/containers/TransferTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './TransferTxContainer'; diff --git a/apps/tangle-dapp/containers/TransferTxContainer/TransferTxContainer.tsx b/apps/tangle-dapp/containers/TransferTxModal.tsx similarity index 91% rename from apps/tangle-dapp/containers/TransferTxContainer/TransferTxContainer.tsx rename to apps/tangle-dapp/containers/TransferTxModal.tsx index fcf00f84c2..8215f60052 100644 --- a/apps/tangle-dapp/containers/TransferTxContainer/TransferTxContainer.tsx +++ b/apps/tangle-dapp/containers/TransferTxModal.tsx @@ -24,16 +24,16 @@ import { } from 'react'; import { isHex } from 'viem'; -import AddressInput, { AddressType } from '../../components/AddressInput'; -import AmountInput from '../../components/AmountInput'; -import useBalances from '../../data/balances/useBalances'; -import useExistentialDeposit from '../../data/balances/useExistentialDeposit'; -import useTransferTx from '../../data/balances/useTransferTx'; -import useActiveAccountAddress from '../../hooks/useActiveAccountAddress'; -import { TxStatus } from '../../hooks/useSubstrateTx'; -import formatTangleBalance from '../../utils/formatTangleBalance'; +import AddressInput, { AddressType } from '../components/AddressInput'; +import AmountInput from '../components/AmountInput'; +import useBalances from '../data/balances/useBalances'; +import useExistentialDeposit from '../data/balances/useExistentialDeposit'; +import useTransferTx from '../data/balances/useTransferTx'; +import useActiveAccountAddress from '../hooks/useActiveAccountAddress'; +import { TxStatus } from '../hooks/useSubstrateTx'; +import formatTangleBalance from '../utils/formatTangleBalance'; -export type TransferTxContainerProps = { +export type TransferTxModalProps = { isModalOpen: boolean; setIsModalOpen: (isModalOpen: boolean) => void; }; @@ -57,7 +57,7 @@ function getTypedChainIdFromAddr(address: string | null): number | undefined { return undefined; } -const TransferTxContainer: FC = ({ +const TransferTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -253,4 +253,4 @@ const TransferTxContainer: FC = ({ ); }; -export default TransferTxContainer; +export default TransferTxModal; diff --git a/apps/tangle-dapp/containers/UnbondTxContainer/index.ts b/apps/tangle-dapp/containers/UnbondTxContainer/index.ts deleted file mode 100644 index 025c1bdba7..0000000000 --- a/apps/tangle-dapp/containers/UnbondTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as UnbondTxContainer } from './UnbondTxContainer'; diff --git a/apps/tangle-dapp/containers/UnbondTxContainer/types.ts b/apps/tangle-dapp/containers/UnbondTxContainer/types.ts deleted file mode 100644 index 90ff2e504f..0000000000 --- a/apps/tangle-dapp/containers/UnbondTxContainer/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type UnbondTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; - -export type UnbondTokensProps = { - amountToUnbond: number; - setAmountToUnbond: (amount: number) => void; - amountToUnbondError?: string; - remainingStakedBalanceToUnbond: number; -}; diff --git a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/types.ts b/apps/tangle-dapp/containers/UpdatePayeeTxContainer/types.ts deleted file mode 100644 index 97d5f4e5dc..0000000000 --- a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { - StakingRewardsDestination, - StakingRewardsDestinationDisplayText, -} from '../../types'; - -export type UpdatePayeeTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; - -export type UpdatePayeeProps = { - payeeOptions: StakingRewardsDestinationDisplayText[]; - selectedPayee: StakingRewardsDestination; - setSelectedPayee: (newPayee: StakingRewardsDestination) => void; -}; diff --git a/apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTableContainer.tsx b/apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTableContainer.tsx deleted file mode 100644 index 90c6eedd70..0000000000 --- a/apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTableContainer.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { ValidatorTable } from '../../components'; -import { ValidatorTableProps } from '../../components/ValidatorTable/types'; - -export default function ValidatorTableContainer(props: ValidatorTableProps) { - return ; -} diff --git a/apps/tangle-dapp/containers/ValidatorTablesContainer/index.ts b/apps/tangle-dapp/containers/ValidatorTablesContainer/index.ts deleted file mode 100644 index bd17483cf5..0000000000 --- a/apps/tangle-dapp/containers/ValidatorTablesContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as ValidatorTablesContainer } from './ValidatorTablesContainer'; diff --git a/apps/tangle-dapp/containers/WalletAndChainContainer/WalletAndChainContainer.tsx b/apps/tangle-dapp/containers/WalletAndChainContainer.tsx similarity index 82% rename from apps/tangle-dapp/containers/WalletAndChainContainer/WalletAndChainContainer.tsx rename to apps/tangle-dapp/containers/WalletAndChainContainer.tsx index 4557e63224..1dc0f44b86 100644 --- a/apps/tangle-dapp/containers/WalletAndChainContainer/WalletAndChainContainer.tsx +++ b/apps/tangle-dapp/containers/WalletAndChainContainer.tsx @@ -3,7 +3,7 @@ import ConnectWalletButton from '@webb-tools/tangle-shared-ui/components/ConnectWalletButton'; import { type FC } from 'react'; -import NetworkSelectionButton from '../../components/NetworkSelectorButton'; +import NetworkSelectionButton from '../components/NetworkSelectorButton'; const WalletAndChainContainer: FC = () => { return ( diff --git a/apps/tangle-dapp/containers/WalletAndChainContainer/index.ts b/apps/tangle-dapp/containers/WalletAndChainContainer/index.ts deleted file mode 100644 index b3b42a11da..0000000000 --- a/apps/tangle-dapp/containers/WalletAndChainContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as WalletAndChainContainer } from './WalletAndChainContainer'; diff --git a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/index.ts b/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/index.ts deleted file mode 100644 index f4e22267a6..0000000000 --- a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as WithdrawUnbondedTxContainer } from './WithdrawUnbondedTxContainer'; diff --git a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/types.ts b/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/types.ts deleted file mode 100644 index aba06e1067..0000000000 --- a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type WithdrawUnbondedTxContainerProps = { - isModalOpen: boolean; - setIsModalOpen: (isModalOpen: boolean) => void; -}; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/BalanceAction.tsx b/apps/tangle-dapp/containers/account/balances/BalanceAction.tsx similarity index 96% rename from apps/tangle-dapp/containers/BalancesTableContainer/BalanceAction.tsx rename to apps/tangle-dapp/containers/account/balances/BalanceAction.tsx index f9f97aa781..f3edc80be6 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/BalanceAction.tsx +++ b/apps/tangle-dapp/containers/account/balances/BalanceAction.tsx @@ -9,7 +9,7 @@ import Link from 'next/link'; import { FC, JSX, ReactNode } from 'react'; import { twMerge } from 'tailwind-merge'; -import { InternalPath } from '../../types'; +import { InternalPath } from '../../../types'; const BalanceAction: FC<{ tooltip: string | ReactNode; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/BalanceCell.tsx b/apps/tangle-dapp/containers/account/balances/BalanceCell.tsx similarity index 93% rename from apps/tangle-dapp/containers/BalancesTableContainer/BalanceCell.tsx rename to apps/tangle-dapp/containers/account/balances/BalanceCell.tsx index dee9f1f809..1f03404bd4 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/BalanceCell.tsx +++ b/apps/tangle-dapp/containers/account/balances/BalanceCell.tsx @@ -12,8 +12,8 @@ import { import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC, ReactNode } from 'react'; -import useActiveAccountAddress from '../../hooks/useActiveAccountAddress'; -import formatTangleBalance from '../../utils/formatTangleBalance'; +import useActiveAccountAddress from '../../../hooks/useActiveAccountAddress'; +import formatTangleBalance from '../../../utils/formatTangleBalance'; const BalanceCell: FC<{ amount: BN | null; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/BalancesTableContainer.tsx b/apps/tangle-dapp/containers/account/balances/BalancesTableContainer.tsx similarity index 94% rename from apps/tangle-dapp/containers/BalancesTableContainer/BalancesTableContainer.tsx rename to apps/tangle-dapp/containers/account/balances/BalancesTableContainer.tsx index 479981d5dd..568b1dfae3 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/BalancesTableContainer.tsx +++ b/apps/tangle-dapp/containers/account/balances/BalancesTableContainer.tsx @@ -19,12 +19,12 @@ import { } from '@webb-tools/webb-ui-components'; import { FC, useCallback, useEffect, useState } from 'react'; -import TangleTokenIcon from '../../components/TangleTokenIcon'; -import useBalances from '../../data/balances/useBalances'; -import useVestingInfo from '../../data/vesting/useVestingInfo'; -import useSubstrateAddress from '../../hooks/useSubstrateAddress'; -import { StaticSearchQueryPath } from '../../types'; -import TransferTxContainer from '../TransferTxContainer/TransferTxContainer'; +import TangleTokenIcon from '../../../components/TangleTokenIcon'; +import useBalances from '../../../data/balances/useBalances'; +import useVestingInfo from '../../../data/vesting/useVestingInfo'; +import useSubstrateAddress from '../../../hooks/useSubstrateAddress'; +import { StaticSearchQueryPath } from '../../../types'; +import TransferTxModal from '../../TransferTxModal'; import BalanceAction from './BalanceAction'; import BalanceCell from './BalanceCell'; import HeaderCell from './HeaderCell'; @@ -170,7 +170,7 @@ const BalancesTableContainer: FC = () => { {hasLocks && !isDetailsCollapsed && } - diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/HeaderCell.tsx b/apps/tangle-dapp/containers/account/balances/HeaderCell.tsx similarity index 100% rename from apps/tangle-dapp/containers/BalancesTableContainer/HeaderCell.tsx rename to apps/tangle-dapp/containers/account/balances/HeaderCell.tsx diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyBalance.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyBalance.tsx similarity index 84% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyBalance.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyBalance.tsx index 7f63e80e3d..55397786c8 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyBalance.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyBalance.tsx @@ -1,6 +1,6 @@ import { FC } from 'react'; -import useDemocracy from '../../../data/democracy/useDemocracy'; +import useDemocracy from '../../../../data/democracy/useDemocracy'; import BalanceCell from '../BalanceCell'; const DemocracyBalance: FC = () => { diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockAction.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockAction.tsx similarity index 81% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockAction.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockAction.tsx index 0d5ded2751..7f21a269e1 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockAction.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockAction.tsx @@ -1,9 +1,9 @@ import { LockUnlockLineIcon } from '@webb-tools/icons'; import { FC } from 'react'; -import useDemocracy from '../../../data/democracy/useDemocracy'; -import useDemocracyUnlockTx from '../../../data/democracy/useDemocracyUnlockTx'; -import { TxStatus } from '../../../hooks/useSubstrateTx'; +import useDemocracy from '../../../../data/democracy/useDemocracy'; +import useDemocracyUnlockTx from '../../../../data/democracy/useDemocracyUnlockTx'; +import { TxStatus } from '../../../../hooks/useSubstrateTx'; import BalanceAction from '../BalanceAction'; const DemocracyUnlockAction: FC = () => { diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockingAt.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockingAt.tsx similarity index 86% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockingAt.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockingAt.tsx index 94b8fd227e..fedde88a2a 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/DemocracyUnlockingAt.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/DemocracyUnlockingAt.tsx @@ -2,10 +2,10 @@ import { formatDecimal } from '@polkadot/util'; import useApiRx from '@webb-tools/tangle-shared-ui/hooks/useApiRx'; import { FC, useCallback } from 'react'; -import useDemocracy from '../../../data/democracy/useDemocracy'; -import useApi from '../../../hooks/useApi'; -import calculateTimeRemaining from '../../../utils/calculateTimeRemaining'; -import getBlockDate from '../../../utils/getBlockDate'; +import useDemocracy from '../../../../data/democracy/useDemocracy'; +import useApi from '../../../../hooks/useApi'; +import calculateTimeRemaining from '../../../../utils/calculateTimeRemaining'; +import getBlockDate from '../../../../utils/getBlockDate'; import TextCell from './TextCell'; const DemocracyUnlockingAt: FC = () => { diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/LockedBalanceDetails.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/LockedBalanceDetails.tsx similarity index 92% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/LockedBalanceDetails.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/LockedBalanceDetails.tsx index c0413850fb..c825ead1c4 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/LockedBalanceDetails.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/LockedBalanceDetails.tsx @@ -4,13 +4,13 @@ import { Chip, Typography } from '@webb-tools/webb-ui-components'; import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC, useMemo } from 'react'; -import { SubstrateLockId } from '../../../constants'; -import useBalancesLock from '../../../data/balances/useBalancesLock'; -import useDemocracy from '../../../data/democracy/useDemocracy'; -import useCurrentEra from '../../../data/staking/useCurrentEra'; -import useUnbonding from '../../../data/staking/useUnbonding'; -import useVestingInfo from '../../../data/vesting/useVestingInfo'; -import { PagePath } from '../../../types'; +import { SubstrateLockId } from '../../../../constants'; +import useBalancesLock from '../../../../data/balances/useBalancesLock'; +import useDemocracy from '../../../../data/democracy/useDemocracy'; +import useCurrentEra from '../../../../data/staking/useCurrentEra'; +import useUnbonding from '../../../../data/staking/useUnbonding'; +import useVestingInfo from '../../../../data/vesting/useVestingInfo'; +import { PagePath } from '../../../../types'; import BalanceAction from '../BalanceAction'; import BalanceCell from '../BalanceCell'; import HeaderCell from '../HeaderCell'; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/TextCell.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/TextCell.tsx similarity index 100% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/TextCell.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/TextCell.tsx diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingRemainingBalances.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingRemainingBalances.tsx similarity index 95% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingRemainingBalances.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingRemainingBalances.tsx index b2d13c084a..600f095b29 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingRemainingBalances.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingRemainingBalances.tsx @@ -2,7 +2,7 @@ import { BN, BN_ZERO } from '@polkadot/util'; import useApiRx from '@webb-tools/tangle-shared-ui/hooks/useApiRx'; import { FC, useCallback } from 'react'; -import useVestingInfo from '../../../data/vesting/useVestingInfo'; +import useVestingInfo from '../../../../data/vesting/useVestingInfo'; import BalanceCell from '../BalanceCell'; import { sortVestingSchedulesAscending } from './VestingScheduleBalances'; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingScheduleBalances.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingScheduleBalances.tsx similarity index 94% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingScheduleBalances.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingScheduleBalances.tsx index 6d8fcf5816..dc8843963c 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingScheduleBalances.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingScheduleBalances.tsx @@ -3,8 +3,8 @@ import { BN, BN_ZERO, formatDecimal } from '@polkadot/util'; import useApiRx from '@webb-tools/tangle-shared-ui/hooks/useApiRx'; import { FC, useCallback } from 'react'; -import useVestingInfo from '../../../data/vesting/useVestingInfo'; -import formatTangleBalance from '../../../utils/formatTangleBalance'; +import useVestingInfo from '../../../../data/vesting/useVestingInfo'; +import formatTangleBalance from '../../../../utils/formatTangleBalance'; import BalanceCell from '../BalanceCell'; /** diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx similarity index 88% rename from apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx rename to apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx index 061439b573..50f86e9006 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx +++ b/apps/tangle-dapp/containers/account/balances/LockedBalanceDetails/VestingSchedulesUnlockingAt.tsx @@ -2,10 +2,10 @@ import { formatDecimal } from '@polkadot/util'; import useApiRx from '@webb-tools/tangle-shared-ui/hooks/useApiRx'; import { FC, useCallback } from 'react'; -import useVestingInfo from '../../../data/vesting/useVestingInfo'; -import useApi from '../../../hooks/useApi'; -import calculateTimeRemaining from '../../../utils/calculateTimeRemaining'; -import getBlockDate from '../../../utils/getBlockDate'; +import useVestingInfo from '../../../../data/vesting/useVestingInfo'; +import useApi from '../../../../hooks/useApi'; +import calculateTimeRemaining from '../../../../utils/calculateTimeRemaining'; +import getBlockDate from '../../../../utils/getBlockDate'; import TextCell from './TextCell'; import { sortVestingSchedulesAscending } from './VestingScheduleBalances'; diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/VestBalanceAction.tsx b/apps/tangle-dapp/containers/account/balances/VestBalanceAction.tsx similarity index 86% rename from apps/tangle-dapp/containers/BalancesTableContainer/VestBalanceAction.tsx rename to apps/tangle-dapp/containers/account/balances/VestBalanceAction.tsx index 8deacc936d..4b083e2c72 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/VestBalanceAction.tsx +++ b/apps/tangle-dapp/containers/account/balances/VestBalanceAction.tsx @@ -1,9 +1,9 @@ import { LockUnlockLineIcon } from '@webb-tools/icons'; import { FC } from 'react'; -import useVestingInfo from '../../data/vesting/useVestingInfo'; -import useVestTx from '../../data/vesting/useVestTx'; -import { TxStatus } from '../../hooks/useSubstrateTx'; +import useVestingInfo from '../../../data/vesting/useVestingInfo'; +import useVestTx from '../../../data/vesting/useVestTx'; +import { TxStatus } from '../../../hooks/useSubstrateTx'; import BalanceAction from './BalanceAction'; const VestBalanceAction: FC = () => { diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/index.ts b/apps/tangle-dapp/containers/account/balances/index.ts similarity index 100% rename from apps/tangle-dapp/containers/BalancesTableContainer/index.ts rename to apps/tangle-dapp/containers/account/balances/index.ts diff --git a/apps/tangle-dapp/containers/BalancesTableContainer/useLongestVestingScheduleTime.ts b/apps/tangle-dapp/containers/account/balances/useLongestVestingScheduleTime.ts similarity index 88% rename from apps/tangle-dapp/containers/BalancesTableContainer/useLongestVestingScheduleTime.ts rename to apps/tangle-dapp/containers/account/balances/useLongestVestingScheduleTime.ts index ef7e752e09..8f6593a12d 100644 --- a/apps/tangle-dapp/containers/BalancesTableContainer/useLongestVestingScheduleTime.ts +++ b/apps/tangle-dapp/containers/account/balances/useLongestVestingScheduleTime.ts @@ -2,10 +2,10 @@ import { formatDecimal } from '@polkadot/util'; import useApiRx from '@webb-tools/tangle-shared-ui/hooks/useApiRx'; import { useCallback } from 'react'; -import useVestingInfo from '../../data/vesting/useVestingInfo'; -import useApi from '../../hooks/useApi'; -import calculateTimeRemaining from '../../utils/calculateTimeRemaining'; -import getBlockDate from '../../utils/getBlockDate'; +import useVestingInfo from '../../../data/vesting/useVestingInfo'; +import useApi from '../../../hooks/useApi'; +import calculateTimeRemaining from '../../../utils/calculateTimeRemaining'; +import getBlockDate from '../../../utils/getBlockDate'; import { sortVestingSchedulesAscending } from './LockedBalanceDetails/VestingScheduleBalances'; const useLongestVestingScheduleTime = () => { diff --git a/apps/tangle-dapp/containers/index.ts b/apps/tangle-dapp/containers/index.ts index 3f940061de..40d0e77224 100644 --- a/apps/tangle-dapp/containers/index.ts +++ b/apps/tangle-dapp/containers/index.ts @@ -1,13 +1,13 @@ -export * from './BondMoreTxContainer'; -export * from './DelegateTxContainer'; export * from './HeaderChipsContainer'; -export * from './KeyStatsContainer'; -export { Layout } from './Layout'; -export * from './NominationsPayoutsContainer'; -export * from './NominatorStatsContainer'; -export * from './RebondTxContainer'; -export * from './UnbondTxContainer'; -export * from './UpdatePayeeTxContainer'; -export * from './ValidatorTablesContainer'; +export * from './Layout'; +export * from './nomination/ActiveAndWaitingValidatorTables'; +export * from './nomination/BondMoreTxContainer'; +export * from './nomination/DelegateTxModal'; +export * from './nomination/KeyStatsContainer'; +export * from './nomination/NominationsPayoutsContainer'; +export * from './nomination/NominatorStatsContainer'; +export * from './nomination/RebondTxModal'; +export * from './nomination/UnbondTxModal'; +export * from './nomination/UpdatePayeeTxContainer'; +export * from './nomination/WithdrawUnbondedTxModal'; export * from './WalletAndChainContainer'; -export * from './WithdrawUnbondedTxContainer'; diff --git a/apps/tangle-dapp/containers/LsCreatePoolModal.tsx b/apps/tangle-dapp/containers/liquidStaking/LsCreatePoolModal.tsx similarity index 89% rename from apps/tangle-dapp/containers/LsCreatePoolModal.tsx rename to apps/tangle-dapp/containers/liquidStaking/LsCreatePoolModal.tsx index 0a08326109..dff624f78e 100644 --- a/apps/tangle-dapp/containers/LsCreatePoolModal.tsx +++ b/apps/tangle-dapp/containers/liquidStaking/LsCreatePoolModal.tsx @@ -13,19 +13,20 @@ import { } from '@webb-tools/webb-ui-components'; import { FC, useCallback, useEffect, useState } from 'react'; -import AddressInput, { AddressType } from '../components/AddressInput'; -import AmountInput from '../components/AmountInput'; -import LsProtocolDropdownInput from '../components/LiquidStaking/LsProtocolDropdownInput'; -import TextInput from '../components/TextInput'; -import { LsNetworkId } from '../constants/liquidStaking/types'; -import useBalances from '../data/balances/useBalances'; -import useLsCreatePoolTx from '../data/liquidStaking/tangle/useLsCreatePoolTx'; -import { useLsStore } from '../data/liquidStaking/useLsStore'; -import useSubstrateAddress from '../hooks/useSubstrateAddress'; -import { TxStatus } from '../hooks/useSubstrateTx'; -import assertSubstrateAddress from '../utils/assertSubstrateAddress'; -import getLsNetwork from '../utils/liquidStaking/getLsNetwork'; -import { ERROR_NOT_ENOUGH_BALANCE } from './ManageProfileModalContainer/Independent/IndependentAllocationInput'; +import AddressInput, { AddressType } from '../../components/AddressInput'; +import AmountInput from '../../components/AmountInput'; +import LsProtocolDropdownInput from '../../components/LiquidStaking/LsProtocolDropdownInput'; +import TextInput from '../../components/TextInput'; +import { LsNetworkId } from '../../constants/liquidStaking/types'; +import useBalances from '../../data/balances/useBalances'; +import useLsCreatePoolTx from '../../data/liquidStaking/tangle/useLsCreatePoolTx'; +import { useLsStore } from '../../data/liquidStaking/useLsStore'; +import useSubstrateAddress from '../../hooks/useSubstrateAddress'; +import { TxStatus } from '../../hooks/useSubstrateTx'; +import assertSubstrateAddress from '../../utils/assertSubstrateAddress'; +import getLsNetwork from '../../utils/liquidStaking/getLsNetwork'; + +export const ERROR_NOT_ENOUGH_BALANCE = 'Not enough available balance'; export type LsCreatePoolModalProps = { isOpen: boolean; diff --git a/apps/tangle-dapp/containers/LsMyProtocolsTable.tsx b/apps/tangle-dapp/containers/liquidStaking/LsMyProtocolsTable.tsx similarity index 91% rename from apps/tangle-dapp/containers/LsMyProtocolsTable.tsx rename to apps/tangle-dapp/containers/liquidStaking/LsMyProtocolsTable.tsx index 4aaa560a7c..b3a6e429c8 100644 --- a/apps/tangle-dapp/containers/LsMyProtocolsTable.tsx +++ b/apps/tangle-dapp/containers/liquidStaking/LsMyProtocolsTable.tsx @@ -20,16 +20,16 @@ import { twMerge } from 'tailwind-merge'; import LsMyPoolsTable, { LsMyPoolRow, -} from '../components/LiquidStaking/LsMyPoolsTable'; -import LsTokenIcon from '../components/LsTokenIcon'; -import StatItem from '../components/StatItem'; -import TableCellWrapper from '../components/tables/TableCellWrapper'; -import { LsToken } from '../constants/liquidStaking/types'; -import useLsMyPools from '../data/liquidStaking/useLsMyPools'; -import { useLsStore } from '../data/liquidStaking/useLsStore'; -import formatBn from '../utils/formatBn'; -import getLsNetwork from '../utils/liquidStaking/getLsNetwork'; -import pluralize from '../utils/pluralize'; +} from '../../components/LiquidStaking/LsMyPoolsTable'; +import LsTokenIcon from '../../components/LiquidStaking/LsTokenIcon'; +import StatItem from '../../components/StatItem'; +import TableCellWrapper from '../../components/tables/TableCellWrapper'; +import { LsToken } from '../../constants/liquidStaking/types'; +import useLsMyPools from '../../data/liquidStaking/useLsMyPools'; +import { useLsStore } from '../../data/liquidStaking/useLsStore'; +import formatBn from '../../utils/formatBn'; +import getLsNetwork from '../../utils/liquidStaking/getLsNetwork'; +import pluralize from '../../utils/pluralize'; export type LsMyProtocolRow = { name: string; diff --git a/apps/tangle-dapp/containers/LsPoolsTable/LsAllProtocolsTable.tsx b/apps/tangle-dapp/containers/liquidStaking/poolTables/LsAllProtocolsTable.tsx similarity index 90% rename from apps/tangle-dapp/containers/LsPoolsTable/LsAllProtocolsTable.tsx rename to apps/tangle-dapp/containers/liquidStaking/poolTables/LsAllProtocolsTable.tsx index 37926637ad..0c5756040c 100644 --- a/apps/tangle-dapp/containers/LsPoolsTable/LsAllProtocolsTable.tsx +++ b/apps/tangle-dapp/containers/liquidStaking/poolTables/LsAllProtocolsTable.tsx @@ -18,15 +18,15 @@ import { TableVariant } from '@webb-tools/webb-ui-components/components/Table/ty import { FC, useCallback, useMemo, useState } from 'react'; import { twMerge } from 'tailwind-merge'; -import LsTokenIcon from '../../components/LsTokenIcon'; -import StatItem from '../../components/StatItem'; -import TableCellWrapper from '../../components/tables/TableCellWrapper'; -import { LsPool, LsToken } from '../../constants/liquidStaking/types'; -import useLsPools from '../../data/liquidStaking/useLsPools'; -import { useLsStore } from '../../data/liquidStaking/useLsStore'; -import formatBn from '../../utils/formatBn'; -import getLsNetwork from '../../utils/liquidStaking/getLsNetwork'; -import pluralize from '../../utils/pluralize'; +import LsTokenIcon from '../../../components/LiquidStaking/LsTokenIcon'; +import StatItem from '../../../components/StatItem'; +import TableCellWrapper from '../../../components/tables/TableCellWrapper'; +import { LsPool, LsToken } from '../../../constants/liquidStaking/types'; +import useLsPools from '../../../data/liquidStaking/useLsPools'; +import { useLsStore } from '../../../data/liquidStaking/useLsStore'; +import formatBn from '../../../utils/formatBn'; +import getLsNetwork from '../../../utils/liquidStaking/getLsNetwork'; +import pluralize from '../../../utils/pluralize'; import LsPoolsTable from './LsPoolsTable'; export type LsProtocolRow = { diff --git a/apps/tangle-dapp/containers/LsPoolsTable/LsPoolsTable.tsx b/apps/tangle-dapp/containers/liquidStaking/poolTables/LsPoolsTable.tsx similarity index 89% rename from apps/tangle-dapp/containers/LsPoolsTable/LsPoolsTable.tsx rename to apps/tangle-dapp/containers/liquidStaking/poolTables/LsPoolsTable.tsx index 3209312862..cb95142f24 100644 --- a/apps/tangle-dapp/containers/LsPoolsTable/LsPoolsTable.tsx +++ b/apps/tangle-dapp/containers/liquidStaking/poolTables/LsPoolsTable.tsx @@ -25,17 +25,17 @@ import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constant import { FC, useMemo, useState } from 'react'; import { twMerge } from 'tailwind-merge'; -import { TableStatus } from '../../components'; -import LstIcon from '../../components/LiquidStaking/LstIcon'; -import PercentageCell from '../../components/tableCells/PercentageCell'; -import TokenAmountCell from '../../components/tableCells/TokenAmountCell'; -import { LsPool } from '../../constants/liquidStaking/types'; -import useLsSetStakingIntent from '../../data/liquidStaking/useLsSetStakingIntent'; -import { useLsStore } from '../../data/liquidStaking/useLsStore'; -import { AmountFormatStyle } from '../../utils/formatDisplayAmount'; -import getLsProtocolDef from '../../utils/liquidStaking/getLsProtocolDef'; -import tryEncodeAddressWithPrefix from '../../utils/liquidStaking/tryEncodeAddressWithPrefix'; -import pluralize from '../../utils/pluralize'; +import LstIcon from '../../../components/LiquidStaking/LstIcon'; +import PercentageCell from '../../../components/tableCells/PercentageCell'; +import TokenAmountCell from '../../../components/tableCells/TokenAmountCell'; +import TableStatus from '../../../components/TableStatus'; +import { LsPool } from '../../../constants/liquidStaking/types'; +import useLsSetStakingIntent from '../../../data/liquidStaking/useLsSetStakingIntent'; +import { useLsStore } from '../../../data/liquidStaking/useLsStore'; +import { AmountFormatStyle } from '../../../utils/formatDisplayAmount'; +import getLsProtocolDef from '../../../utils/liquidStaking/getLsProtocolDef'; +import tryEncodeAddressWithPrefix from '../../../utils/liquidStaking/tryEncodeAddressWithPrefix'; +import pluralize from '../../../utils/pluralize'; export type LsPoolsTableProps = { pools: LsPool[]; diff --git a/apps/tangle-dapp/containers/LsPoolsTable/index.ts b/apps/tangle-dapp/containers/liquidStaking/poolTables/index.ts similarity index 100% rename from apps/tangle-dapp/containers/LsPoolsTable/index.ts rename to apps/tangle-dapp/containers/liquidStaking/poolTables/index.ts diff --git a/apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTablesContainer.tsx b/apps/tangle-dapp/containers/nomination/ActiveAndWaitingValidatorTables.tsx similarity index 85% rename from apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTablesContainer.tsx rename to apps/tangle-dapp/containers/nomination/ActiveAndWaitingValidatorTables.tsx index 04438f3bd3..ddd125dc66 100644 --- a/apps/tangle-dapp/containers/ValidatorTablesContainer/ValidatorTablesContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/ActiveAndWaitingValidatorTables.tsx @@ -9,15 +9,16 @@ import { } from '@webb-tools/webb-ui-components'; import { useState } from 'react'; -import { ContainerSkeleton, TableStatus } from '../../components'; -import useActiveValidators from '../../data/ValidatorTables/useActiveValidators'; -import useWaitingValidators from '../../data/ValidatorTables/useWaitingValidators'; -import ValidatorTableContainer from './ValidatorTableContainer'; +import { ContainerSkeleton } from '../../components'; +import TableStatus from '../../components/TableStatus'; +import ValidatorTable from '../../components/ValidatorTable'; +import useActiveValidators from '../../data/validators/useActiveValidators'; +import useWaitingValidators from '../../data/validators/useWaitingValidators'; const activeValidatorsTableTab = 'Active Validators'; const waitingValidatorsTableTab = 'Waiting'; -const ValidatorTablesContainer = () => { +const ActiveAndWaitingValidatorTables = () => { const { network } = useNetworkStore(); const { validators: activeValidatorsData } = useActiveValidators(); const { validators: waitingValidatorsData } = useWaitingValidators(); @@ -61,7 +62,7 @@ const ValidatorTablesContainer = () => { ) : isActiveValidatorsLoading ? ( ) : ( - @@ -86,7 +87,7 @@ const ValidatorTablesContainer = () => { ) : isWaitingValidatorsLoading ? ( ) : ( - { ); }; -export default ValidatorTablesContainer; +export default ActiveAndWaitingValidatorTables; diff --git a/apps/tangle-dapp/containers/BondMoreTxContainer/BondMoreTxContainer.tsx b/apps/tangle-dapp/containers/nomination/BondMoreTxContainer.tsx similarity index 89% rename from apps/tangle-dapp/containers/BondMoreTxContainer/BondMoreTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/BondMoreTxContainer.tsx index 8f86d72282..abe04755e8 100644 --- a/apps/tangle-dapp/containers/BondMoreTxContainer/BondMoreTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/BondMoreTxContainer.tsx @@ -13,9 +13,20 @@ import { TANGLE_DOCS_STAKING_URL } from '@webb-tools/webb-ui-components/constant import { type FC, useCallback, useEffect, useState } from 'react'; import AmountInput from '../../components/AmountInput'; -import useTokenWalletFreeBalance from '../../data/NominatorStats/useTokenWalletFreeBalance'; +import useTokenWalletFreeBalance from '../../data/nomination/useTokenWalletFreeBalance'; import useBondExtraTx from '../../data/staking/useBondExtraTx'; -import { BondMoreTxContainerProps } from './types'; + +export type BondMoreTxContainerProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + +export type BondTokensProps = { + amountToBond: number; + setAmountToBond: (amount: number) => void; + amountToBondError?: string; + amountWalletBalance: number; +}; const BondMoreTxContainer: FC = ({ isModalOpen, diff --git a/apps/tangle-dapp/containers/DelegateTxContainer/BondTokens.tsx b/apps/tangle-dapp/containers/nomination/DelegateTxModal/BondTokens.tsx similarity index 92% rename from apps/tangle-dapp/containers/DelegateTxContainer/BondTokens.tsx rename to apps/tangle-dapp/containers/nomination/DelegateTxModal/BondTokens.tsx index cd26b917e0..5e7de509a0 100644 --- a/apps/tangle-dapp/containers/DelegateTxContainer/BondTokens.tsx +++ b/apps/tangle-dapp/containers/nomination/DelegateTxModal/BondTokens.tsx @@ -9,14 +9,14 @@ import _ from 'lodash'; import { type FC, useCallback } from 'react'; import z from 'zod'; -import AmountInput from '../../components/AmountInput'; +import AmountInput from '../../../components/AmountInput'; import { STAKING_PAYEE_TEXT_TO_VALUE_MAP, STAKING_PAYEE_VALUE_TO_TEXT_MAP, -} from '../../constants'; -import useBalances from '../../data/balances/useBalances'; -import useActiveAccountAddress from '../../hooks/useActiveAccountAddress'; -import { StakingRewardsDestinationDisplayText } from '../../types/index'; +} from '../../../constants'; +import useBalances from '../../../data/balances/useBalances'; +import useActiveAccountAddress from '../../../hooks/useActiveAccountAddress'; +import { StakingRewardsDestinationDisplayText } from '../../../types/index'; import { BondTokensProps } from './types'; const RESPONSIVE_DUO_GRID_CLASS = diff --git a/apps/tangle-dapp/containers/DelegateTxContainer/DelegateTxContainer.tsx b/apps/tangle-dapp/containers/nomination/DelegateTxModal/DelegateTxModal.tsx similarity index 90% rename from apps/tangle-dapp/containers/DelegateTxContainer/DelegateTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/DelegateTxModal/DelegateTxModal.tsx index 483e3a9df7..0fb87cb9a7 100644 --- a/apps/tangle-dapp/containers/DelegateTxContainer/DelegateTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/DelegateTxModal/DelegateTxModal.tsx @@ -14,21 +14,21 @@ import { TANGLE_DOCS_STAKING_URL } from '@webb-tools/webb-ui-components/constant import assert from 'assert'; import { type FC, useCallback, useState } from 'react'; -import { PAYMENT_DESTINATION_OPTIONS as PAYEE_OPTIONS } from '../../constants'; -import useStakingRewardsDestination from '../../data/NominatorStats/useStakingRewardsDestination'; -import useIsBondedOrNominating from '../../data/staking/useIsBondedOrNominating'; -import useSetupNominatorTx from '../../data/staking/useSetupNominatorTx'; -import useUpdateNominatorTx from '../../data/staking/useUpdateNominatorTx'; -import useActiveAccountAddress from '../../hooks/useActiveAccountAddress'; -import useMaxNominationQuota from '../../hooks/useMaxNominationQuota'; -import { TxStatus } from '../../hooks/useSubstrateTx'; -import { StakingRewardsDestination } from '../../types'; -import pluralize from '../../utils/pluralize'; +import { PAYMENT_DESTINATION_OPTIONS as PAYEE_OPTIONS } from '../../../constants'; +import useStakingRewardsDestination from '../../../data/nomination/useStakingRewardsDestination'; +import useIsBondedOrNominating from '../../../data/staking/useIsBondedOrNominating'; +import useSetupNominatorTx from '../../../data/staking/useSetupNominatorTx'; +import useUpdateNominatorTx from '../../../data/staking/useUpdateNominatorTx'; +import useActiveAccountAddress from '../../../hooks/useActiveAccountAddress'; +import useMaxNominationQuota from '../../../hooks/useMaxNominationQuota'; +import { TxStatus } from '../../../hooks/useSubstrateTx'; +import { StakingRewardsDestination } from '../../../types'; +import pluralize from '../../../utils/pluralize'; import SelectValidators from '../UpdateNominationsTxContainer/SelectValidators'; import BondTokens from './BondTokens'; -import { DelegateTxContainerProps, DelegateTxSteps } from './types'; +import { DelegateTxModalProps, DelegateTxSteps } from './types'; -const DelegateTxContainer: FC = ({ +const DelegateTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -257,4 +257,4 @@ const DelegateTxContainer: FC = ({ ); }; -export default DelegateTxContainer; +export default DelegateTxModal; diff --git a/apps/tangle-dapp/containers/nomination/DelegateTxModal/index.ts b/apps/tangle-dapp/containers/nomination/DelegateTxModal/index.ts new file mode 100644 index 0000000000..ddddc9125d --- /dev/null +++ b/apps/tangle-dapp/containers/nomination/DelegateTxModal/index.ts @@ -0,0 +1 @@ +export { default as DelegateTxModal } from './DelegateTxModal'; diff --git a/apps/tangle-dapp/containers/DelegateTxContainer/types.ts b/apps/tangle-dapp/containers/nomination/DelegateTxModal/types.ts similarity index 94% rename from apps/tangle-dapp/containers/DelegateTxContainer/types.ts rename to apps/tangle-dapp/containers/nomination/DelegateTxModal/types.ts index 8e4e3c35ef..d890c91e20 100644 --- a/apps/tangle-dapp/containers/DelegateTxContainer/types.ts +++ b/apps/tangle-dapp/containers/nomination/DelegateTxModal/types.ts @@ -4,9 +4,9 @@ import { StakingRewardsDestination, StakingRewardsDestinationDisplayText, Validator, -} from '../../types'; +} from '../../../types'; -export type DelegateTxContainerProps = { +export type DelegateTxModalProps = { isModalOpen: boolean; setIsModalOpen: (isModalOpen: boolean) => void; }; diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/ActiveValidatorsKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActiveValidatorsKeyStat.tsx similarity index 76% rename from apps/tangle-dapp/containers/KeyStatsContainer/ActiveValidatorsKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActiveValidatorsKeyStat.tsx index 4115be91a8..5bef52990d 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/ActiveValidatorsKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActiveValidatorsKeyStat.tsx @@ -3,8 +3,8 @@ import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useActiveAndDelegationCountSubscription from '../../data/KeyStats/useActiveAndDelegationCountSubscription'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useActiveAndDelegationCountSubscription from '../../../data/KeyStats/useActiveAndDelegationCountSubscription'; const ActiveValidatorsKeyStat: FC = () => { const { data, isLoading, error } = useActiveAndDelegationCountSubscription(); diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx similarity index 79% rename from apps/tangle-dapp/containers/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx index a2697ed0c3..00218f2f6c 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ActualStakedPercentageKeyStat.tsx @@ -2,8 +2,8 @@ import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useActualStakedPercentage from '../../data/staking/useActualStakedPercentage'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useActualStakedPercentage from '../../../data/staking/useActualStakedPercentage'; const ActualStakedPercentageKeyStat: FC = () => { const actualStakedPercentage = useActualStakedPercentage(); diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx similarity index 80% rename from apps/tangle-dapp/containers/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx index fbc94541b1..01bd3dcdf6 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/IdealStakedPercentageKeyStat.tsx @@ -3,8 +3,8 @@ import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useIdealStakePercentage from '../../data/KeyStats/useIdealStakePercentage'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useIdealStakePercentage from '../../../data/KeyStats/useIdealStakePercentage'; const IdealStakedPercentageKeyStat: FC = () => { const { data, isLoading, error } = useIdealStakePercentage(); diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/InflationPercentageKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/InflationPercentageKeyStat.tsx similarity index 76% rename from apps/tangle-dapp/containers/KeyStatsContainer/InflationPercentageKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/InflationPercentageKeyStat.tsx index 767e87b2c1..9badc65de3 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/InflationPercentageKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/InflationPercentageKeyStat.tsx @@ -2,8 +2,8 @@ import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useInflationPercentage from '../../data/KeyStats/useInflationPercentage'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useInflationPercentage from '../../../data/KeyStats/useInflationPercentage'; const InflationPercentageKeyStat: FC = () => { const { data, isLoading, error } = useInflationPercentage(); diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/KeyStatsContainer.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/KeyStatsContainer.tsx similarity index 100% rename from apps/tangle-dapp/containers/KeyStatsContainer/KeyStatsContainer.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/KeyStatsContainer.tsx diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/ValidatorCountKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ValidatorCountKeyStat.tsx similarity index 81% rename from apps/tangle-dapp/containers/KeyStatsContainer/ValidatorCountKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/ValidatorCountKeyStat.tsx index 0e896a421c..a7209e0e15 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/ValidatorCountKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/ValidatorCountKeyStat.tsx @@ -3,8 +3,8 @@ import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useValidatorCountSubscription from '../../data/KeyStats/useValidatorsCountSubscription'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useValidatorCountSubscription from '../../../data/KeyStats/useValidatorsCountSubscription'; const ValidatorCountKeyStat: FC = () => { const { diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/WaitingValidatorsKeyStat.tsx b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/WaitingValidatorsKeyStat.tsx similarity index 78% rename from apps/tangle-dapp/containers/KeyStatsContainer/WaitingValidatorsKeyStat.tsx rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/WaitingValidatorsKeyStat.tsx index 534247881b..ec2f8e81ef 100644 --- a/apps/tangle-dapp/containers/KeyStatsContainer/WaitingValidatorsKeyStat.tsx +++ b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/WaitingValidatorsKeyStat.tsx @@ -3,8 +3,8 @@ import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; import { FC } from 'react'; -import KeyStatsItem from '../../components/KeyStatsItem/KeyStatsItem'; -import useWaitingCountSubscription from '../../data/KeyStats/useWaitingCountSubscription'; +import KeyStatsItem from '../../../components/nomination/KeyStatsItem'; +import useWaitingCountSubscription from '../../../data/KeyStats/useWaitingCountSubscription'; const WaitingValidatorsKeyStat: FC = () => { const { data, error, isLoading } = useWaitingCountSubscription(); diff --git a/apps/tangle-dapp/containers/KeyStatsContainer/index.ts b/apps/tangle-dapp/containers/nomination/KeyStatsContainer/index.ts similarity index 100% rename from apps/tangle-dapp/containers/KeyStatsContainer/index.ts rename to apps/tangle-dapp/containers/nomination/KeyStatsContainer/index.ts diff --git a/apps/tangle-dapp/containers/NominationsPayoutsContainer/NominationsPayoutsContainer.tsx b/apps/tangle-dapp/containers/nomination/NominationsPayoutsContainer.tsx similarity index 94% rename from apps/tangle-dapp/containers/NominationsPayoutsContainer/NominationsPayoutsContainer.tsx rename to apps/tangle-dapp/containers/nomination/NominationsPayoutsContainer.tsx index 79e250ef40..e20f293bb4 100644 --- a/apps/tangle-dapp/containers/NominationsPayoutsContainer/NominationsPayoutsContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/NominationsPayoutsContainer.tsx @@ -21,15 +21,13 @@ import { useState, } from 'react'; -import { - ContainerSkeleton, - NominationsTable, - PayoutTable, - TableStatus, -} from '../../components'; -import useNominations from '../../data/NominationsPayouts/useNominations'; -import usePayouts from '../../data/NominationsPayouts/usePayouts'; +import { ContainerSkeleton } from '../../components'; +import NominationsTable from '../../components/nomination/NominationsTable'; +import PayoutTable from '../../components/nomination/PayoutTable'; +import TableStatus from '../../components/TableStatus'; +import useNominations from '../../data/nomination/useNominations'; import { MAX_PAYOUTS_BATCH_SIZE } from '../../data/payouts/usePayoutAllTx'; +import usePayouts from '../../data/payouts/usePayouts'; import { usePayoutsStore } from '../../data/payouts/usePayoutsStore'; import useIsBondedOrNominating from '../../data/staking/useIsBondedOrNominating'; import { PayoutsEraRange } from '../../data/types'; @@ -39,11 +37,11 @@ import { DelegationsAndPayoutsTab as NominationsAndPayoutsTab, QueryParamKey, } from '../../types'; -import { DelegateTxContainer } from '../DelegateTxContainer'; -import { PayoutAllTxContainer } from '../PayoutAllTxContainer'; -import { StopNominationTxContainer } from '../StopNominationTxContainer'; -import { UpdateNominationsTxContainer } from '../UpdateNominationsTxContainer'; -import { UpdatePayeeTxContainer } from '../UpdatePayeeTxContainer'; +import { DelegateTxModal } from './DelegateTxModal'; +import PayoutAllTxModal from './PayoutAllTxModal'; +import StopNominationTxModal from './StopNominationTxModal'; +import { UpdateNominationsTxContainer } from './UpdateNominationsTxContainer'; +import { UpdatePayeeTxContainer } from './UpdatePayeeTxContainer'; const PAGE_SIZE = 10; @@ -288,7 +286,7 @@ const DelegationsPayoutsContainer: FC = () => { - @@ -305,12 +303,12 @@ const DelegationsPayoutsContainer: FC = () => { setIsModalOpen={setIsUpdatePayeeModalOpen} /> - - { const [isDelegateModalOpen, setIsDelegateModalOpen] = useState(false); @@ -222,7 +223,7 @@ const NominatorStatsContainer: FC = () => {
- @@ -232,17 +233,17 @@ const NominatorStatsContainer: FC = () => { setIsModalOpen={setIsBondMoreModalOpen} /> - - - diff --git a/apps/tangle-dapp/containers/PayoutAllTxContainer/PayoutAllTxContainer.tsx b/apps/tangle-dapp/containers/nomination/PayoutAllTxModal.tsx similarity index 91% rename from apps/tangle-dapp/containers/PayoutAllTxContainer/PayoutAllTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/PayoutAllTxModal.tsx index 7c4ea43d30..b7b57d4312 100644 --- a/apps/tangle-dapp/containers/PayoutAllTxContainer/PayoutAllTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/PayoutAllTxModal.tsx @@ -1,5 +1,6 @@ 'use client'; +import { Payout } from '@webb-tools/tangle-shared-ui/types'; import { InputField, Modal, @@ -17,9 +18,21 @@ import usePayoutAllTx, { } from '../../data/payouts/usePayoutAllTx'; import useSubstrateAddress from '../../hooks/useSubstrateAddress'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { PayoutAllTxContainerProps } from './types'; -const PayoutAllTxContainer: FC = ({ +export type PayoutTxProps = { + validatorSubstrateAddress: string; + era: number; +}; + +export type PayoutAllTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; + validatorsAndEras: PayoutTxProps[]; + payouts: Payout[]; + onComplete: () => void; +}; + +const PayoutAllTxModal: FC = ({ isModalOpen, setIsModalOpen, validatorsAndEras, @@ -159,4 +172,4 @@ const PayoutAllTxContainer: FC = ({ ); }; -export default PayoutAllTxContainer; +export default PayoutAllTxModal; diff --git a/apps/tangle-dapp/containers/PayoutTxContainer/PayoutTxContainer.tsx b/apps/tangle-dapp/containers/nomination/PayoutTxModal.tsx similarity index 91% rename from apps/tangle-dapp/containers/PayoutTxContainer/PayoutTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/PayoutTxModal.tsx index 31fa9edf68..c9428d3e79 100644 --- a/apps/tangle-dapp/containers/PayoutTxContainer/PayoutTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/PayoutTxModal.tsx @@ -1,6 +1,7 @@ 'use client'; import { useWebContext } from '@webb-tools/api-provider-environment'; +import { Payout } from '@webb-tools/tangle-shared-ui/types'; import { InputField, Modal, @@ -16,9 +17,20 @@ import { type FC, useCallback, useMemo } from 'react'; import { MAX_PAYOUTS_BATCH_SIZE } from '../../data/payouts/usePayoutAllTx'; import usePayoutStakersTx from '../../data/payouts/usePayoutStakersTx'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { PayoutTxContainerProps } from './types'; -const PayoutTxContainer: FC = ({ +export type PayoutTxProps = { + validatorAddress: string; + era: number; +}; + +export type PayoutTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; + payoutTxProps: PayoutTxProps; + payouts: Payout[]; +}; + +const PayoutTxModal: FC = ({ isModalOpen, setIsModalOpen, payoutTxProps: { validatorAddress, era }, @@ -132,4 +144,4 @@ const PayoutTxContainer: FC = ({ ); }; -export default PayoutTxContainer; +export default PayoutTxModal; diff --git a/apps/tangle-dapp/containers/RebondTxContainer/RebondTxContainer.tsx b/apps/tangle-dapp/containers/nomination/RebondTxModal.tsx similarity index 84% rename from apps/tangle-dapp/containers/RebondTxContainer/RebondTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/RebondTxModal.tsx index 6ffede9301..812f47c834 100644 --- a/apps/tangle-dapp/containers/RebondTxContainer/RebondTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/RebondTxModal.tsx @@ -14,13 +14,26 @@ import { type FC, useCallback, useState } from 'react'; import { BondedTokensBalanceInfo } from '../../components'; import AmountInput from '../../components/AmountInput'; -import useUnbondedAmount from '../../data/NominatorStats/useUnbondedAmount'; -import useUnbondingAmount from '../../data/NominatorStats/useUnbondingAmount'; +import useUnbondedAmount from '../../data/nomination/useUnbondedAmount'; +import useUnbondingAmount from '../../data/nomination/useUnbondingAmount'; import useRebondTx from '../../data/staking/useRebondTx'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { RebondTxContainerProps } from './types'; -const RebondTxContainer: FC = ({ +export type RebondTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + +export type RebondTokensProps = { + amountToRebond: number; + setAmountToRebond: (amount: number) => void; + amountToRebondError?: string; + remainingUnbondedTokensToRebond: number; + unbondedAmount: number; + unbondingAmount: number; +}; + +const RebondTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -117,4 +130,4 @@ const RebondTxContainer: FC = ({ ); }; -export default RebondTxContainer; +export default RebondTxModal; diff --git a/apps/tangle-dapp/containers/StopNominationTxContainer/StopNominationTxContainer.tsx b/apps/tangle-dapp/containers/nomination/StopNominationTxModal.tsx similarity index 89% rename from apps/tangle-dapp/containers/StopNominationTxContainer/StopNominationTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/StopNominationTxModal.tsx index 91e3b9d2a5..d69014187a 100644 --- a/apps/tangle-dapp/containers/StopNominationTxContainer/StopNominationTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/StopNominationTxModal.tsx @@ -15,9 +15,13 @@ import { type FC, useCallback } from 'react'; import useChillTx from '../../data/staking/useChillTx'; import useIsNominating from '../../hooks/useIsNominating'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { StopNominationTxContainerProps } from './types'; -const StopNominationTxContainer: FC = ({ +export type StopNominationTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + +const StopNominationTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -69,4 +73,4 @@ const StopNominationTxContainer: FC = ({ ); }; -export default StopNominationTxContainer; +export default StopNominationTxModal; diff --git a/apps/tangle-dapp/containers/UnbondTxContainer/UnbondTxContainer.tsx b/apps/tangle-dapp/containers/nomination/UnbondTxModal.tsx similarity index 88% rename from apps/tangle-dapp/containers/UnbondTxContainer/UnbondTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/UnbondTxModal.tsx index 118565d58d..34908e410e 100644 --- a/apps/tangle-dapp/containers/UnbondTxContainer/UnbondTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/UnbondTxModal.tsx @@ -15,13 +15,24 @@ import { TANGLE_DOCS_STAKING_URL } from '@webb-tools/webb-ui-components/constant import { type FC, useCallback, useMemo, useState } from 'react'; import AmountInput from '../../components/AmountInput'; -import useTotalStakedAmountSubscription from '../../data/NominatorStats/useTotalStakedAmountSubscription'; -import useUnbondingAmount from '../../data/NominatorStats/useUnbondingAmount'; +import useTotalStakedAmountSubscription from '../../data/nomination/useTotalStakedAmountSubscription'; +import useUnbondingAmount from '../../data/nomination/useUnbondingAmount'; import useUnbondTx from '../../data/staking/useUnbondTx'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { UnbondTxContainerProps } from './types'; -const UnbondTxContainer: FC = ({ +export type UnbondTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + +export type UnbondTokensProps = { + amountToUnbond: number; + setAmountToUnbond: (amount: number) => void; + amountToUnbondError?: string; + remainingStakedBalanceToUnbond: number; +}; + +const UnbondTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -152,4 +163,4 @@ const UnbondTxContainer: FC = ({ ); }; -export default UnbondTxContainer; +export default UnbondTxModal; diff --git a/apps/tangle-dapp/containers/UpdateNominationsTxContainer/SelectValidators.tsx b/apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/SelectValidators.tsx similarity index 83% rename from apps/tangle-dapp/containers/UpdateNominationsTxContainer/SelectValidators.tsx rename to apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/SelectValidators.tsx index 3f13ce76fb..87257243c8 100644 --- a/apps/tangle-dapp/containers/UpdateNominationsTxContainer/SelectValidators.tsx +++ b/apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/SelectValidators.tsx @@ -1,8 +1,8 @@ import { Alert } from '@webb-tools/webb-ui-components'; import React, { Dispatch, type FC, SetStateAction } from 'react'; -import ValidatorSelectionTable from '../../components/ValidatorSelectionTable/ValidatorSelectionTable'; -import useAllValidators from '../../data/ValidatorTables/useAllValidators'; +import ValidatorSelectionTable from '../../../components/ValidatorSelectionTable'; +import useAllValidators from '../../../data/validators/useAllValidators'; export type SelectValidatorsProps = { defaultSelectedValidators?: string[]; diff --git a/apps/tangle-dapp/containers/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx b/apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx similarity index 95% rename from apps/tangle-dapp/containers/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx index 7fee73dbcc..8097696ce3 100644 --- a/apps/tangle-dapp/containers/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/UpdateNominationsTxContainer.tsx @@ -18,9 +18,9 @@ import { useState, } from 'react'; -import useNominateTx from '../../data/staking/useNominateTx'; -import useMaxNominationQuota from '../../hooks/useMaxNominationQuota'; -import { TxStatus } from '../../hooks/useSubstrateTx'; +import useNominateTx from '../../../data/staking/useNominateTx'; +import useMaxNominationQuota from '../../../hooks/useMaxNominationQuota'; +import { TxStatus } from '../../../hooks/useSubstrateTx'; import SelectValidators from './SelectValidators'; export type UpdateNominationsTxContainerProps = { diff --git a/apps/tangle-dapp/containers/UpdateNominationsTxContainer/index.ts b/apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/index.ts similarity index 100% rename from apps/tangle-dapp/containers/UpdateNominationsTxContainer/index.ts rename to apps/tangle-dapp/containers/nomination/UpdateNominationsTxContainer/index.ts diff --git a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayee.tsx b/apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayee.tsx similarity index 78% rename from apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayee.tsx rename to apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayee.tsx index e59ff5f951..3cf20b7a65 100644 --- a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayee.tsx +++ b/apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayee.tsx @@ -5,9 +5,17 @@ import { z } from 'zod'; import { STAKING_PAYEE_TEXT_TO_VALUE_MAP, STAKING_PAYEE_VALUE_TO_TEXT_MAP, -} from '../../constants'; -import { StakingRewardsDestinationDisplayText } from '../../types'; -import { UpdatePayeeProps } from './types'; +} from '../../../constants'; +import { + StakingRewardsDestination, + StakingRewardsDestinationDisplayText, +} from '../../../types'; + +export type UpdatePayeeProps = { + payeeOptions: StakingRewardsDestinationDisplayText[]; + selectedPayee: StakingRewardsDestination; + setSelectedPayee: (newPayee: StakingRewardsDestination) => void; +}; const UpdatePayee: FC = ({ payeeOptions, diff --git a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx b/apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx similarity index 81% rename from apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx index ff9bad2e3f..9ca91c3e45 100644 --- a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/UpdatePayeeTxContainer.tsx @@ -10,14 +10,18 @@ import { import { TANGLE_DOCS_STAKING_URL } from '@webb-tools/webb-ui-components/constants'; import { type FC, useCallback, useState } from 'react'; -import { PAYMENT_DESTINATION_OPTIONS } from '../../constants'; -import useStakingRewardsDestination from '../../data/NominatorStats/useStakingRewardsDestination'; -import useSetPayeeTx from '../../data/staking/useSetPayeeTx'; -import { TxStatus } from '../../hooks/useSubstrateTx'; -import { StakingRewardsDestination } from '../../types'; -import { UpdatePayeeTxContainerProps } from './types'; +import { PAYMENT_DESTINATION_OPTIONS } from '../../../constants'; +import useStakingRewardsDestination from '../../../data/nomination/useStakingRewardsDestination'; +import useSetPayeeTx from '../../../data/staking/useSetPayeeTx'; +import { TxStatus } from '../../../hooks/useSubstrateTx'; +import { StakingRewardsDestination } from '../../../types'; import UpdatePayee from './UpdatePayee'; +export type UpdatePayeeTxContainerProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + const UpdatePayeeTxContainer: FC = ({ isModalOpen, setIsModalOpen, diff --git a/apps/tangle-dapp/containers/UpdatePayeeTxContainer/index.ts b/apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/index.ts similarity index 100% rename from apps/tangle-dapp/containers/UpdatePayeeTxContainer/index.ts rename to apps/tangle-dapp/containers/nomination/UpdatePayeeTxContainer/index.ts diff --git a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/WithdrawUnbondedTxContainer.tsx b/apps/tangle-dapp/containers/nomination/WithdrawUnbondedTxModal.tsx similarity index 83% rename from apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/WithdrawUnbondedTxContainer.tsx rename to apps/tangle-dapp/containers/nomination/WithdrawUnbondedTxModal.tsx index 86d0b667e5..80965cfa95 100644 --- a/apps/tangle-dapp/containers/WithdrawUnbondedTxContainer/WithdrawUnbondedTxContainer.tsx +++ b/apps/tangle-dapp/containers/nomination/WithdrawUnbondedTxModal.tsx @@ -11,15 +11,19 @@ import { } from '@webb-tools/webb-ui-components'; import { type FC, useCallback, useState } from 'react'; -import { BondedTokensBalanceInfo } from '../../components/BondedTokensBalanceInfo'; -import useUnbondedAmount from '../../data/NominatorStats/useUnbondedAmount'; -import useUnbondingAmount from '../../data/NominatorStats/useUnbondingAmount'; +import { BondedTokensBalanceInfo } from '../../components/nomination/BondedTokensBalanceInfo'; +import useUnbondedAmount from '../../data/nomination/useUnbondedAmount'; +import useUnbondingAmount from '../../data/nomination/useUnbondingAmount'; import useWithdrawUnbondedTx from '../../data/staking/useWithdrawUnbondedTx'; import { TxStatus } from '../../hooks/useSubstrateTx'; -import { RebondTxContainer } from '../RebondTxContainer'; -import { WithdrawUnbondedTxContainerProps } from './types'; +import RebondTxModal from './RebondTxModal'; -const WithdrawUnbondedTxContainer: FC = ({ +export type WithdrawUnbondedTxModalProps = { + isModalOpen: boolean; + setIsModalOpen: (isModalOpen: boolean) => void; +}; + +const WithdrawUnbondedTxModal: FC = ({ isModalOpen, setIsModalOpen, }) => { @@ -100,7 +104,7 @@ const WithdrawUnbondedTxContainer: FC = ({ - @@ -108,4 +112,4 @@ const WithdrawUnbondedTxContainer: FC = ({ ); }; -export default WithdrawUnbondedTxContainer; +export default WithdrawUnbondedTxModal; diff --git a/apps/tangle-dapp/context/ErrorsContext.tsx b/apps/tangle-dapp/context/ErrorsContext.tsx deleted file mode 100644 index 3f0365a6aa..0000000000 --- a/apps/tangle-dapp/context/ErrorsContext.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { - Dispatch, - SetStateAction, - useCallback, - useContext, -} from 'react'; - -const ErrorSetContext = React.createContext<{ - errors: Set; - setErrors: Dispatch>>; -}>({ - errors: new Set(), - setErrors: () => { - // - }, -}); - -/** - * Useful for inputs of a form or any other component that - * needs to keep track of the number of errors that are currently - * present, but that may be deeply nested in the component tree, - * and would be impractical to pass the error count down through props. - */ -export const useErrorCountContext = () => { - const { errors, setErrors } = useContext(ErrorSetContext); - - const addError = useCallback( - (error: string) => { - setErrors((prevErrors) => new Set([...prevErrors, error])); - }, - [setErrors], - ); - - const removeError = useCallback( - (error: string) => { - setErrors((prevErrors) => { - const newErrors = new Set(prevErrors); - - newErrors.delete(error); - - return newErrors; - }); - }, - [setErrors], - ); - - const clearErrors = useCallback(() => { - setErrors(new Set()); - }, [setErrors]); - - return { errors, addError, removeError, clearErrors }; -}; diff --git a/apps/tangle-dapp/context/useOnboardingStore.tsx b/apps/tangle-dapp/context/useOnboardingStore.tsx deleted file mode 100644 index 045d90fa6d..0000000000 --- a/apps/tangle-dapp/context/useOnboardingStore.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { create } from 'zustand'; - -const useOnboardingStore = create<{ - onboardingReopenFlag: boolean; - setOnboardingReopenFlag: (flag: boolean) => void; -}>((set) => ({ - onboardingReopenFlag: false, - setOnboardingReopenFlag: (onboardingReopenFlag) => - set({ onboardingReopenFlag }), -})); - -export default useOnboardingStore; diff --git a/apps/tangle-dapp/context/useSearchParamsStore.ts b/apps/tangle-dapp/context/useSearchParamsStore.ts deleted file mode 100644 index c23e7953d3..0000000000 --- a/apps/tangle-dapp/context/useSearchParamsStore.ts +++ /dev/null @@ -1,68 +0,0 @@ -'use client'; - -import { ReadonlyURLSearchParams, useSearchParams } from 'next/navigation'; -import { useCallback, useEffect, useRef } from 'react'; -import { create } from 'zustand'; - -// A global, centralized store of search params is needed -// to prevent data races when multiple hook instances are -// trying to update the search params at the same time. -const useSearchParamsZustandStore = create<{ - searchParams: ReadonlyURLSearchParams | null; - setSearchParams: (searchParams: ReadonlyURLSearchParams) => void; -}>((set) => ({ - searchParams: null, - setSearchParams: (searchParams) => set({ searchParams }), -})); - -const useSearchParamsStore = () => { - const routerSearchParams = useSearchParams(); - - const { - searchParams: bufferSearchParams, - setSearchParams: setBufferSearchParams, - } = useSearchParamsZustandStore(); - - const didInitializeRef = useRef(false); - - useEffect(() => { - if (didInitializeRef.current || routerSearchParams === null) { - return; - } - - didInitializeRef.current = true; - setBufferSearchParams(routerSearchParams); - }, [routerSearchParams, setBufferSearchParams]); - - // TODO: Sort params by name so that after each update, the URL search params don't "flicker" due to their positions changing. - const updateSearchParam = useCallback( - (key: string, value: string | undefined) => { - if (bufferSearchParams === null) { - return; - } - - const newSearchParams = new URLSearchParams( - bufferSearchParams.toString(), - ); - - if (value === undefined) { - newSearchParams.delete(key); - } else { - newSearchParams.set(key, value); - } - - const newReadonlySearchParams = new ReadonlyURLSearchParams( - newSearchParams, - ); - - setBufferSearchParams(newReadonlySearchParams); - - return newReadonlySearchParams; - }, - [bufferSearchParams, setBufferSearchParams], - ); - - return { searchParams: bufferSearchParams, updateSearchParam }; -}; - -export default useSearchParamsStore; diff --git a/apps/tangle-dapp/data/balances/useTransferTx.ts b/apps/tangle-dapp/data/balances/useTransferTx.ts index 9ce6daf266..87b9a660a8 100644 --- a/apps/tangle-dapp/data/balances/useTransferTx.ts +++ b/apps/tangle-dapp/data/balances/useTransferTx.ts @@ -4,7 +4,7 @@ import { shortenString } from '@webb-tools/webb-ui-components/utils/shortenStrin import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { AbiCall, EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useEvmPrecompileFeeFetcher from '../../hooks/useEvmPrecompileFee'; diff --git a/apps/tangle-dapp/data/index.ts b/apps/tangle-dapp/data/index.ts index b001d144c8..3bdcf2f0b2 100644 --- a/apps/tangle-dapp/data/index.ts +++ b/apps/tangle-dapp/data/index.ts @@ -1,3 +1,3 @@ export { default as useEraCountSubscription } from './useEraCountSubscription'; export { default as useSessionCountSubscription } from './useSessionCountSubscription'; -export * from './ValidatorTables'; +export * from './validators'; diff --git a/apps/tangle-dapp/data/liquidStaking/tangle/useLsCreatePoolTx.ts b/apps/tangle-dapp/data/liquidStaking/tangle/useLsCreatePoolTx.ts index ff7805caaf..68e9f2c420 100644 --- a/apps/tangle-dapp/data/liquidStaking/tangle/useLsCreatePoolTx.ts +++ b/apps/tangle-dapp/data/liquidStaking/tangle/useLsCreatePoolTx.ts @@ -3,7 +3,7 @@ import { useCallback } from 'react'; import { Address } from 'viem'; import { TxName } from '../../../constants'; -import { Precompile } from '../../../constants/evmPrecompiles'; +import { Precompile } from '../../../constants/precompiles'; import useAgnosticTx from '../../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolJoinTx.ts b/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolJoinTx.ts index d33f2222f8..1ed2e07835 100644 --- a/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolJoinTx.ts +++ b/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolJoinTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../../constants'; -import { Precompile } from '../../../constants/evmPrecompiles'; +import { Precompile } from '../../../constants/precompiles'; import useAgnosticTx from '../../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolUnbondTx.ts b/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolUnbondTx.ts index ac05f4aeb0..3e8836af5b 100644 --- a/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolUnbondTx.ts +++ b/apps/tangle-dapp/data/liquidStaking/tangle/useLsPoolUnbondTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../../constants'; -import { Precompile } from '../../../constants/evmPrecompiles'; +import { Precompile } from '../../../constants/precompiles'; import useAgnosticTx from '../../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/liquidStaking/useLsWithdrawUnbondedTx.ts b/apps/tangle-dapp/data/liquidStaking/useLsWithdrawUnbondedTx.ts index 7a5252118f..13dd483c7e 100644 --- a/apps/tangle-dapp/data/liquidStaking/useLsWithdrawUnbondedTx.ts +++ b/apps/tangle-dapp/data/liquidStaking/useLsWithdrawUnbondedTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/NominationsPayouts/useNominations.ts b/apps/tangle-dapp/data/nomination/useNominations.ts similarity index 96% rename from apps/tangle-dapp/data/NominationsPayouts/useNominations.ts rename to apps/tangle-dapp/data/nomination/useNominations.ts index 50332127cd..be7e1a9067 100644 --- a/apps/tangle-dapp/data/NominationsPayouts/useNominations.ts +++ b/apps/tangle-dapp/data/nomination/useNominations.ts @@ -9,7 +9,7 @@ import { Nominee } from '../../types/index'; import createNominee from '../../utils/staking/createNominee'; import useStakingExposures from '../staking/useStakingExposures'; import useValidatorPrefs from '../staking/useValidatorPrefs'; -import useValidatorIdentityNames from '../ValidatorTables/useValidatorIdentityNames'; +import useValidatorIdentityNames from '../validators/useValidatorIdentityNames'; const useNominations = () => { const activeSubstrateAddress = useSubstrateAddress(); diff --git a/apps/tangle-dapp/data/NominatorStats/useStakingRewardsDestination.ts b/apps/tangle-dapp/data/nomination/useStakingRewardsDestination.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useStakingRewardsDestination.ts rename to apps/tangle-dapp/data/nomination/useStakingRewardsDestination.ts diff --git a/apps/tangle-dapp/data/NominatorStats/useTokenWalletFreeBalance.ts b/apps/tangle-dapp/data/nomination/useTokenWalletFreeBalance.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useTokenWalletFreeBalance.ts rename to apps/tangle-dapp/data/nomination/useTokenWalletFreeBalance.ts diff --git a/apps/tangle-dapp/data/NominatorStats/useTotalPayoutRewards.ts b/apps/tangle-dapp/data/nomination/useTotalPayoutRewards.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useTotalPayoutRewards.ts rename to apps/tangle-dapp/data/nomination/useTotalPayoutRewards.ts diff --git a/apps/tangle-dapp/data/NominatorStats/useTotalStakedAmountSubscription.ts b/apps/tangle-dapp/data/nomination/useTotalStakedAmountSubscription.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useTotalStakedAmountSubscription.ts rename to apps/tangle-dapp/data/nomination/useTotalStakedAmountSubscription.ts diff --git a/apps/tangle-dapp/data/NominatorStats/useUnbondedAmount.ts b/apps/tangle-dapp/data/nomination/useUnbondedAmount.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useUnbondedAmount.ts rename to apps/tangle-dapp/data/nomination/useUnbondedAmount.ts diff --git a/apps/tangle-dapp/data/NominatorStats/useUnbondingAmount.ts b/apps/tangle-dapp/data/nomination/useUnbondingAmount.ts similarity index 100% rename from apps/tangle-dapp/data/NominatorStats/useUnbondingAmount.ts rename to apps/tangle-dapp/data/nomination/useUnbondingAmount.ts diff --git a/apps/tangle-dapp/data/payouts/usePayoutAllTx.ts b/apps/tangle-dapp/data/payouts/usePayoutAllTx.ts index 2a6a490645..4c442e5077 100644 --- a/apps/tangle-dapp/data/payouts/usePayoutAllTx.ts +++ b/apps/tangle-dapp/data/payouts/usePayoutAllTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/payouts/usePayoutStakersTx.ts b/apps/tangle-dapp/data/payouts/usePayoutStakersTx.ts index 6e9fc2fa8a..ea1dac31a7 100644 --- a/apps/tangle-dapp/data/payouts/usePayoutStakersTx.ts +++ b/apps/tangle-dapp/data/payouts/usePayoutStakersTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/NominationsPayouts/usePayouts.ts b/apps/tangle-dapp/data/payouts/usePayouts.ts similarity index 96% rename from apps/tangle-dapp/data/NominationsPayouts/usePayouts.ts rename to apps/tangle-dapp/data/payouts/usePayouts.ts index 34dbd2eb5a..4d89a0fc2a 100644 --- a/apps/tangle-dapp/data/NominationsPayouts/usePayouts.ts +++ b/apps/tangle-dapp/data/payouts/usePayouts.ts @@ -19,11 +19,11 @@ import { getApiPromise as getPolkadotApiPromise } from '@webb-tools/tangle-share import { useCallback, useEffect, useMemo } from 'react'; import useSubstrateAddress from '../../hooks/useSubstrateAddress'; -import useEraTotalRewards from '../payouts/useEraTotalRewards'; -import useNominationsUnclaimedRewards from '../payouts/useNominationsUnclaimedRewards'; -import { usePayoutsStore } from '../payouts/usePayoutsStore'; import { ValidatorReward } from '../types'; -import useValidatorIdentityNames from '../ValidatorTables/useValidatorIdentityNames'; +import useValidatorIdentityNames from '../validators/useValidatorIdentityNames'; +import useEraTotalRewards from './useEraTotalRewards'; +import useNominationsUnclaimedRewards from './useNominationsUnclaimedRewards'; +import { usePayoutsStore } from './usePayoutsStore'; type UsePayoutsReturnType = { isLoading: boolean; diff --git a/apps/tangle-dapp/data/restake/RestakeTx/evm.ts b/apps/tangle-dapp/data/restake/RestakeTx/evm.ts index d5ad52df70..12f69a675c 100644 --- a/apps/tangle-dapp/data/restake/RestakeTx/evm.ts +++ b/apps/tangle-dapp/data/restake/RestakeTx/evm.ts @@ -20,7 +20,7 @@ import { import { BATCH_PRECOMPILE_ABI, PrecompileAddress, -} from '../../../constants/evmPrecompiles'; +} from '../../../constants/precompiles'; import createEvmBatchCallArgs from '../../../utils/staking/createEvmBatchCallArgs'; import toEvmAddress32 from '../../../utils/toEvmAddress32'; import restakeAbi from './abi'; diff --git a/apps/tangle-dapp/data/roleEarningsChart/getProtocolEarningsChartData.ts b/apps/tangle-dapp/data/roleEarningsChart/getProtocolEarningsChartData.ts deleted file mode 100644 index df4311ad73..0000000000 --- a/apps/tangle-dapp/data/roleEarningsChart/getProtocolEarningsChartData.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { randNumber } from '@ngneat/falso'; - -import type { RoleEarningsChartItem } from '../../components/charts/types'; - -const randNum = () => randNumber({ min: 1000, max: 4000, precision: 100 }); - -export default async function getProtocolEarningsChartData(): Promise< - RoleEarningsChartItem[] -> { - return Array.from({ length: randNumber({ min: 10, max: 20 }) }).map( - (_, idx) => ({ - era: idx + 1, - reward: randNum(), - }), - ); -} diff --git a/apps/tangle-dapp/data/roleEarningsChart/index.ts b/apps/tangle-dapp/data/roleEarningsChart/index.ts deleted file mode 100644 index 211093b9a5..0000000000 --- a/apps/tangle-dapp/data/roleEarningsChart/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as getProtocolEarningsChartData } from './getProtocolEarningsChartData'; diff --git a/apps/tangle-dapp/data/staking/useBondExtraTx.ts b/apps/tangle-dapp/data/staking/useBondExtraTx.ts index 2f35ba42b3..7b12d31121 100644 --- a/apps/tangle-dapp/data/staking/useBondExtraTx.ts +++ b/apps/tangle-dapp/data/staking/useBondExtraTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; diff --git a/apps/tangle-dapp/data/staking/useChillTx.ts b/apps/tangle-dapp/data/staking/useChillTx.ts index edb8b6a1db..56b7bb6c7b 100644 --- a/apps/tangle-dapp/data/staking/useChillTx.ts +++ b/apps/tangle-dapp/data/staking/useChillTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/staking/useNominateTx.ts b/apps/tangle-dapp/data/staking/useNominateTx.ts index 07abc57cba..8a2f9b220c 100644 --- a/apps/tangle-dapp/data/staking/useNominateTx.ts +++ b/apps/tangle-dapp/data/staking/useNominateTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/staking/useRebondTx.ts b/apps/tangle-dapp/data/staking/useRebondTx.ts index 3be7629216..e3d7543944 100644 --- a/apps/tangle-dapp/data/staking/useRebondTx.ts +++ b/apps/tangle-dapp/data/staking/useRebondTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; diff --git a/apps/tangle-dapp/data/staking/useSetPayeeTx.ts b/apps/tangle-dapp/data/staking/useSetPayeeTx.ts index 5b906261e7..2b033ebbc4 100644 --- a/apps/tangle-dapp/data/staking/useSetPayeeTx.ts +++ b/apps/tangle-dapp/data/staking/useSetPayeeTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import { SubstrateTxFactory } from '../../hooks/useSubstrateTx'; diff --git a/apps/tangle-dapp/data/staking/useSetupNominatorTx.ts b/apps/tangle-dapp/data/staking/useSetupNominatorTx.ts index e9a118b6aa..0795de0b77 100644 --- a/apps/tangle-dapp/data/staking/useSetupNominatorTx.ts +++ b/apps/tangle-dapp/data/staking/useSetupNominatorTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; diff --git a/apps/tangle-dapp/data/staking/useUnbondTx.ts b/apps/tangle-dapp/data/staking/useUnbondTx.ts index 9f5c248340..74b03b2fcb 100644 --- a/apps/tangle-dapp/data/staking/useUnbondTx.ts +++ b/apps/tangle-dapp/data/staking/useUnbondTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; diff --git a/apps/tangle-dapp/data/staking/useUpdateNominatorTx.ts b/apps/tangle-dapp/data/staking/useUpdateNominatorTx.ts index 702f6791f6..3e8500ce39 100644 --- a/apps/tangle-dapp/data/staking/useUpdateNominatorTx.ts +++ b/apps/tangle-dapp/data/staking/useUpdateNominatorTx.ts @@ -3,7 +3,7 @@ import { ISubmittableResult } from '@polkadot/types/types'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { AbiBatchCallData, diff --git a/apps/tangle-dapp/data/staking/useWithdrawUnbondedTx.ts b/apps/tangle-dapp/data/staking/useWithdrawUnbondedTx.ts index 93eee32328..c341684f29 100644 --- a/apps/tangle-dapp/data/staking/useWithdrawUnbondedTx.ts +++ b/apps/tangle-dapp/data/staking/useWithdrawUnbondedTx.ts @@ -2,7 +2,7 @@ import { BN } from '@polkadot/util'; import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; import { EvmTxFactory } from '../../hooks/useEvmPrecompileAbiCall'; import useFormatNativeTokenAmount from '../../hooks/useFormatNativeTokenAmount'; diff --git a/apps/tangle-dapp/data/ValidatorTables/index.ts b/apps/tangle-dapp/data/validators/index.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/index.ts rename to apps/tangle-dapp/data/validators/index.ts diff --git a/apps/tangle-dapp/data/ValidatorTables/useActiveValidators.ts b/apps/tangle-dapp/data/validators/useActiveValidators.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/useActiveValidators.ts rename to apps/tangle-dapp/data/validators/useActiveValidators.ts diff --git a/apps/tangle-dapp/data/ValidatorTables/useAllValidators.ts b/apps/tangle-dapp/data/validators/useAllValidators.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/useAllValidators.ts rename to apps/tangle-dapp/data/validators/useAllValidators.ts diff --git a/apps/tangle-dapp/data/ValidatorTables/useValidatorIdentityNames.ts b/apps/tangle-dapp/data/validators/useValidatorIdentityNames.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/useValidatorIdentityNames.ts rename to apps/tangle-dapp/data/validators/useValidatorIdentityNames.ts diff --git a/apps/tangle-dapp/data/ValidatorTables/useValidators.ts b/apps/tangle-dapp/data/validators/useValidators.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/useValidators.ts rename to apps/tangle-dapp/data/validators/useValidators.ts diff --git a/apps/tangle-dapp/data/ValidatorTables/useWaitingValidators.ts b/apps/tangle-dapp/data/validators/useWaitingValidators.ts similarity index 100% rename from apps/tangle-dapp/data/ValidatorTables/useWaitingValidators.ts rename to apps/tangle-dapp/data/validators/useWaitingValidators.ts diff --git a/apps/tangle-dapp/data/vesting/useVestTx.ts b/apps/tangle-dapp/data/vesting/useVestTx.ts index dc429a8536..eb0e02ea13 100644 --- a/apps/tangle-dapp/data/vesting/useVestTx.ts +++ b/apps/tangle-dapp/data/vesting/useVestTx.ts @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { TxName } from '../../constants'; -import { Precompile } from '../../constants/evmPrecompiles'; +import { Precompile } from '../../constants/precompiles'; import useAgnosticTx from '../../hooks/useAgnosticTx'; /** diff --git a/apps/tangle-dapp/hooks/useAgnosticTx.ts b/apps/tangle-dapp/hooks/useAgnosticTx.ts index a75df45773..028861f286 100644 --- a/apps/tangle-dapp/hooks/useAgnosticTx.ts +++ b/apps/tangle-dapp/hooks/useAgnosticTx.ts @@ -3,7 +3,7 @@ import useSubstrateExplorerUrl from '@webb-tools/tangle-shared-ui/hooks/useSubst import { useCallback, useEffect, useState } from 'react'; import { TxName } from '../constants'; -import { Precompile } from '../constants/evmPrecompiles'; +import { Precompile } from '../constants/precompiles'; import { GetSuccessMessageFunction } from '../types'; import useActiveAccountAddress from './useActiveAccountAddress'; import useAgnosticAccountInfo from './useAgnosticAccountInfo'; diff --git a/apps/tangle-dapp/hooks/useEvmPrecompileAbiCall.ts b/apps/tangle-dapp/hooks/useEvmPrecompileAbiCall.ts index 2556ff6011..7205e5e0af 100644 --- a/apps/tangle-dapp/hooks/useEvmPrecompileAbiCall.ts +++ b/apps/tangle-dapp/hooks/useEvmPrecompileAbiCall.ts @@ -17,7 +17,7 @@ import { getPrecompileAddress, Precompile, PrecompileAddress, -} from '../constants/evmPrecompiles'; +} from '../constants/precompiles'; import useEvmAddress20 from './useEvmAddress'; import { TxStatus } from './useSubstrateTx'; diff --git a/apps/tangle-dapp/hooks/useEvmPrecompileFee.ts b/apps/tangle-dapp/hooks/useEvmPrecompileFee.ts index 782f942067..993a3a69cf 100644 --- a/apps/tangle-dapp/hooks/useEvmPrecompileFee.ts +++ b/apps/tangle-dapp/hooks/useEvmPrecompileFee.ts @@ -7,7 +7,7 @@ import { getPrecompileAbi, getPrecompileAddress, type Precompile, -} from '../constants/evmPrecompiles'; +} from '../constants/precompiles'; import useEvmAddress20 from './useEvmAddress'; import { AbiCall } from './useEvmPrecompileAbiCall'; import useViemPublicClient from './useViemPublicClient'; diff --git a/apps/tangle-dapp/utils/staking/createEvmBatchCallData.ts b/apps/tangle-dapp/utils/staking/createEvmBatchCallData.ts index 54ddef83ea..f34ef65a52 100644 --- a/apps/tangle-dapp/utils/staking/createEvmBatchCallData.ts +++ b/apps/tangle-dapp/utils/staking/createEvmBatchCallData.ts @@ -5,7 +5,7 @@ import { getPrecompileAbi, getPrecompileAddress, Precompile, -} from '../../constants/evmPrecompiles'; +} from '../../constants/precompiles'; import { AbiEncodeableValue } from '../../hooks/useEvmPrecompileAbiCall'; import { AbiBatchCallArgs, From 891ddfec584da2e719b61f9a4aa76af69ae7da86 Mon Sep 17 00:00:00 2001 From: yurixander <101931215+yurixander@users.noreply.github.com> Date: Sat, 30 Nov 2024 02:08:30 +0100 Subject: [PATCH 2/4] fix(tangle-dapp): Import fixes --- .../constants/liquidStaking/constants.ts | 2 +- apps/tangle-dapp/containers/Layout.tsx | 18 ++++++++++++++---- .../data/evm/useContractReadBatch.ts | 2 +- .../data/evm/useContractReadOnce.ts | 2 +- apps/tangle-dapp/data/evm/useContractWrite.ts | 2 +- .../webb-ui-components/src/next-utils/index.ts | 1 - .../src/next-utils/useLayoutBgClassName.ts | 13 ------------- 7 files changed, 18 insertions(+), 22 deletions(-) delete mode 100644 libs/webb-ui-components/src/next-utils/useLayoutBgClassName.ts diff --git a/apps/tangle-dapp/constants/liquidStaking/constants.ts b/apps/tangle-dapp/constants/liquidStaking/constants.ts index f340c159de..34996530dd 100644 --- a/apps/tangle-dapp/constants/liquidStaking/constants.ts +++ b/apps/tangle-dapp/constants/liquidStaking/constants.ts @@ -8,7 +8,7 @@ import POLKADOT from '../../data/liquidStaking/adapters/polkadot'; import TANGLE_LOCAL from '../../data/liquidStaking/adapters/tangleLocal'; import TANGLE_MAINNET from '../../data/liquidStaking/adapters/tangleMainnet'; import TANGLE_TESTNET from '../../data/liquidStaking/adapters/tangleTestnet'; -import { IS_PRODUCTION_ENV } from '../env'; +import { IS_PRODUCTION_ENV } from '..'; import { LsNetwork, LsNetworkId, diff --git a/apps/tangle-dapp/containers/Layout.tsx b/apps/tangle-dapp/containers/Layout.tsx index 8c7f30ccd9..06d7fc9349 100644 --- a/apps/tangle-dapp/containers/Layout.tsx +++ b/apps/tangle-dapp/containers/Layout.tsx @@ -8,11 +8,13 @@ import { TANGLE_TERMS_OF_SERVICE_URL, WEBB_AVAILABLE_SOCIALS, } from '@webb-tools/webb-ui-components/constants'; -import { useLayoutBgClassName } from '@webb-tools/webb-ui-components/next-utils'; +import { usePathname } from 'next/navigation'; import { type FC, type PropsWithChildren } from 'react'; +import { twMerge } from 'tailwind-merge'; import { BridgeTxQueueDropdown, MobileSidebar, Sidebar } from '../components'; -import { IS_PRODUCTION_ENV } from '../constants/env'; +import { IS_PRODUCTION_ENV } from '../constants'; +import { PagePath } from '../types'; import DebugMetrics from './DebugMetrics'; import WalletAndChainContainer from './WalletAndChainContainer'; @@ -33,14 +35,22 @@ interface LayoutProps { isSidebarInitiallyExpanded: boolean | undefined; } +const useLayoutBgClass = () => { + const pathname = usePathname(); + + return pathname.startsWith(PagePath.LIQUID_STAKING) + ? 'ls-bg-body' + : 'bg-body'; +}; + const Layout: FC> = ({ isSidebarInitiallyExpanded, children, }) => { - const layoutBgClassname = useLayoutBgClassName(); + const layoutBgClass = useLayoutBgClass(); return ( -
+
diff --git a/apps/tangle-dapp/data/evm/useContractReadBatch.ts b/apps/tangle-dapp/data/evm/useContractReadBatch.ts index 6c486ab5c2..19e8113ec1 100644 --- a/apps/tangle-dapp/data/evm/useContractReadBatch.ts +++ b/apps/tangle-dapp/data/evm/useContractReadBatch.ts @@ -9,7 +9,7 @@ import { } from 'viem'; import { mainnet, sepolia } from 'viem/chains'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../constants'; import usePolling from '../liquidStaking/usePolling'; import { ContractReadOptions } from './useContractReadOnce'; import useViemPublicClientWithChain from './useViemPublicClientWithChain'; diff --git a/apps/tangle-dapp/data/evm/useContractReadOnce.ts b/apps/tangle-dapp/data/evm/useContractReadOnce.ts index 2310f283c6..a3f55f83ef 100644 --- a/apps/tangle-dapp/data/evm/useContractReadOnce.ts +++ b/apps/tangle-dapp/data/evm/useContractReadOnce.ts @@ -10,7 +10,7 @@ import { import { mainnet, sepolia } from 'viem/chains'; import { ReadContractReturnType } from 'wagmi/actions'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../constants'; import useDebugMetricsStore from '../../context/useDebugMetricsStore'; import useViemPublicClientWithChain from './useViemPublicClientWithChain'; diff --git a/apps/tangle-dapp/data/evm/useContractWrite.ts b/apps/tangle-dapp/data/evm/useContractWrite.ts index a4f81ac9ec..9cd6c3089d 100644 --- a/apps/tangle-dapp/data/evm/useContractWrite.ts +++ b/apps/tangle-dapp/data/evm/useContractWrite.ts @@ -23,7 +23,7 @@ import { mainnet, sepolia } from 'viem/chains'; import { useConnectorClient } from 'wagmi'; import { TxName } from '../../constants'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../constants'; import useEvmAddress20 from '../../hooks/useEvmAddress'; import useTxNotification, { NotificationSteps, diff --git a/libs/webb-ui-components/src/next-utils/index.ts b/libs/webb-ui-components/src/next-utils/index.ts index 04ee3046e1..0f24c7fb73 100644 --- a/libs/webb-ui-components/src/next-utils/index.ts +++ b/libs/webb-ui-components/src/next-utils/index.ts @@ -1,2 +1 @@ export * from './sidebarState'; -export * from './useLayoutBgClassName'; diff --git a/libs/webb-ui-components/src/next-utils/useLayoutBgClassName.ts b/libs/webb-ui-components/src/next-utils/useLayoutBgClassName.ts deleted file mode 100644 index 4cd0d93ab4..0000000000 --- a/libs/webb-ui-components/src/next-utils/useLayoutBgClassName.ts +++ /dev/null @@ -1,13 +0,0 @@ -'use client'; - -import { usePathname } from 'next/navigation'; - -export const useLayoutBgClassName = () => { - const pathname = usePathname(); - - if (pathname.includes('/liquid-staking')) { - return 'ls-bg-body'; - } - - return 'bg-body'; -}; From 979988e03f67e0e692dfd8d3925b2b9245802bcd Mon Sep 17 00:00:00 2001 From: yurixander <101931215+yurixander@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:52:34 +0100 Subject: [PATCH 3/4] fix(tangle-dapp): Fix build errors --- apps/tangle-dapp/app/restake/unstake/page.tsx | 1 + .../stakeAndUnstake/LsNetworkSwitcher.tsx | 2 +- .../RestakeAssetDetailCard.tsx | 68 ++++++ .../RestakeOperatorDetailCard.tsx | 107 +++++++++ .../components/RestakeDetailCard/index.tsx | 214 ++++++++++++++++++ .../components/RestakeDetailCard/utils.ts | 13 ++ .../utils/liquidStaking/getLsTangleNetwork.ts | 2 +- 7 files changed, 405 insertions(+), 2 deletions(-) create mode 100644 apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx create mode 100644 apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx create mode 100644 apps/tangle-dapp/components/RestakeDetailCard/index.tsx create mode 100644 apps/tangle-dapp/components/RestakeDetailCard/utils.ts diff --git a/apps/tangle-dapp/app/restake/unstake/page.tsx b/apps/tangle-dapp/app/restake/unstake/page.tsx index abc08d12ff..3a190f37e9 100644 --- a/apps/tangle-dapp/app/restake/unstake/page.tsx +++ b/apps/tangle-dapp/app/restake/unstake/page.tsx @@ -24,6 +24,7 @@ import { formatUnits, parseUnits } from 'viem'; import AvatarWithText from '../../../components/AvatarWithText'; import ErrorMessage from '../../../components/ErrorMessage'; +import RestakeDetailCard from '../../../components/RestakeDetailCard'; import { SUPPORTED_RESTAKE_DEPOSIT_TYPED_CHAIN_IDS } from '../../../constants/restake'; import { useRestakeContext } from '../../../context/RestakeContext'; import { diff --git a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsNetworkSwitcher.tsx b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsNetworkSwitcher.tsx index 24b2ce5691..a0daa8950a 100644 --- a/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsNetworkSwitcher.tsx +++ b/apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/LsNetworkSwitcher.tsx @@ -14,7 +14,7 @@ import { import { FC, useCallback, useMemo } from 'react'; import { twMerge } from 'tailwind-merge'; -import { IS_PRODUCTION_ENV } from '../../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../../constants'; import { LS_NETWORKS } from '../../../constants/liquidStaking/constants'; import { LsNetworkId } from '../../../constants/liquidStaking/types'; import { NETWORK_FEATURE_MAP } from '../../../constants/networks'; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx b/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx new file mode 100644 index 0000000000..8be4777e3e --- /dev/null +++ b/apps/tangle-dapp/components/RestakeDetailCard/RestakeAssetDetailCard.tsx @@ -0,0 +1,68 @@ +import { ArrowRightUp } from '@webb-tools/icons/ArrowRightUp'; +import { TokenIcon } from '@webb-tools/icons/TokenIcon'; +import Button from '@webb-tools/webb-ui-components/components/buttons/Button'; + +import RestakeDetailCard from '.'; +import { getDisplayValue } from './utils'; + +type RestakeAssetDetailCardProps = { + assetExternalLink?: string; + getAssetLink?: string; + limit?: string | number; + name?: string; + symbol?: string; + tvl?: string | number; +}; + +const RestakeAssetDetailCard = ({ + assetExternalLink, + getAssetLink, + limit, + name, + symbol, + tvl, +}: RestakeAssetDetailCardProps) => { + return ( + + + } + RightElement={ + getAssetLink ? ( + + ) : undefined + } + title={symbol} + description={name} + descExternalLink={assetExternalLink} + /> + + + + {getDisplayValue(tvl)} + + + + {getDisplayValue(limit)} + + + + ); +}; + +export default RestakeAssetDetailCard; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx b/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx new file mode 100644 index 0000000000..2bb2b2c29a --- /dev/null +++ b/apps/tangle-dapp/components/RestakeDetailCard/RestakeOperatorDetailCard.tsx @@ -0,0 +1,107 @@ +'use client'; + +import GlobalLine from '@webb-tools/icons/GlobalLine'; +import { Mail } from '@webb-tools/icons/Mail'; +import MapPinLine from '@webb-tools/icons/MapPinLine'; +import { TwitterFill } from '@webb-tools/icons/TwitterFill'; +import { Avatar } from '@webb-tools/webb-ui-components/components/Avatar'; +import { Chip } from '@webb-tools/webb-ui-components/components/Chip'; +import { KeyValueWithButton } from '@webb-tools/webb-ui-components/components/KeyValueWithButton'; +import { shortenString } from '@webb-tools/webb-ui-components/utils/shortenString'; +import { cloneElement, ReactElement } from 'react'; + +import RestakeDetailCard from '.'; +import { getDisplayValue } from './utils'; + +type RestakeOperatorDetailCardProps = { + delegationCount?: number; + identityEmailLink?: string; + identityName?: string; + identityWebLink?: string; + identityXLink?: string; + isDelegated?: boolean; + operatorAccountId?: string; + totalStaked?: string | number; + validatorExternalLink?: string; + location?: string; +}; + +const RestakeOperatorDetailCard = ({ + delegationCount, + identityEmailLink, + identityName, + identityXLink, + identityWebLink, + isDelegated, + operatorAccountId = '', + totalStaked, + validatorExternalLink, + location = 'Unknown', +}: RestakeOperatorDetailCardProps) => { + return ( + + + } + RightElement={ + isDelegated ? DELEGATED : undefined + } + title={identityName || shortenString(operatorAccountId ?? '')} + description={ + + } + descExternalLink={validatorExternalLink} + /> + + + + {getDisplayValue(totalStaked)} + + + + {getDisplayValue(delegationCount)} + + + +
+
+ {identityXLink && ( + } /> + )} + + {identityEmailLink && ( + } /> + )} + + {identityWebLink && ( + } /> + )} +
+ + + + + {location} + +
+
+ ); +}; + +export default RestakeOperatorDetailCard; + +const SocialLink = ({ href, Icon }: { href?: string; Icon: ReactElement }) => { + return ( + + + {cloneElement(Icon, { className: '!fill-current' })} + + + ); +}; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/index.tsx b/apps/tangle-dapp/components/RestakeDetailCard/index.tsx new file mode 100644 index 0000000000..0fb9a81a0b --- /dev/null +++ b/apps/tangle-dapp/components/RestakeDetailCard/index.tsx @@ -0,0 +1,214 @@ +import { isPrimitive } from '@webb-tools/dapp-types'; +import { ExternalLinkLine } from '@webb-tools/icons/ExternalLinkLine'; +import { TitleWithInfo } from '@webb-tools/webb-ui-components/components/TitleWithInfo'; +import { Typography } from '@webb-tools/webb-ui-components/typography/Typography'; +import { + type ComponentProps, + ForwardedRef, + forwardRef, + type JSXElementConstructor, + type ReactElement, + type ReactNode, +} from 'react'; +import { twMerge } from 'tailwind-merge'; + +type ElementBase = string | JSXElementConstructor; + +type RestakeDetailCardRootProps = ComponentProps<'div'>; + +const RestakeDetailCardRoot = forwardRef< + HTMLDivElement, + RestakeDetailCardRootProps +>(({ className, children, ...props }, ref) => { + return ( +
+ {children} +
+ ); +}); + +RestakeDetailCardRoot.displayName = 'RestakeDetailCardRoot'; + +type RestakeDetailCardHeaderProps< + IconProps, + RightElementProps, + IconElement extends ElementBase = ElementBase, + RightElement extends ElementBase = ElementBase, +> = ComponentProps<'div'> & { + IconElement?: ReactElement; + title?: ReactNode; + description?: ReactNode; + descExternalLink?: string; + RightElement?: ReactElement; +}; + +const RestakeDetailCardHeader = forwardRef( + < + IconProps, + RightElementProps, + IconEl extends ElementBase = ElementBase, + RightEl extends ElementBase = ElementBase, + >( + { + className, + title, + description, + descExternalLink, + RightElement, + IconElement, + ...props + }: RestakeDetailCardHeaderProps< + IconProps, + RightElementProps, + IconEl, + RightEl + >, + ref: ForwardedRef, + ) => { + return ( +
+
+ {IconElement} + +
+ {isPrimitive(title) && title !== null && title !== undefined ? ( + + {title} + + ) : ( + title + )} + +
+ {isPrimitive(description) && + description !== null && + description !== undefined ? ( + + {description} + + ) : ( + description + )} + + {descExternalLink && ( + + + + )} +
+
+
+ + {RightElement} +
+ ); + }, +); + +RestakeDetailCardHeader.displayName = 'RestakeDetailCardHeader'; + +type RestakeDetailCardBodyProps = ComponentProps<'div'>; + +const RestakeDetailCardBody = forwardRef< + HTMLDivElement, + RestakeDetailCardBodyProps +>(({ className, children, ...props }, ref) => { + return ( +
+ {children} +
+ ); +}); + +RestakeDetailCardBody.displayName = 'RestakeDetailCardBody'; + +type RestakeDetailCardItemProps = ComponentProps<'div'> & { + title: string; + tooltip?: ReactNode; +}; + +const RestakeDetailCardItem = forwardRef< + HTMLDivElement, + RestakeDetailCardItemProps +>(({ className, title, tooltip, children, ...props }, ref) => { + return ( +
+ {isPrimitive(children) ? ( + + {children} + + ) : ( + children + )} + + +
+ ); +}); + +RestakeDetailCardItem.displayName = 'RestakeDetailCardItem'; + +const RestakeDetailCard = Object.assign( + {}, + { + Root: RestakeDetailCardRoot, + Header: RestakeDetailCardHeader, + Body: RestakeDetailCardBody, + Item: RestakeDetailCardItem, + }, +); + +export type { + RestakeDetailCardBodyProps, + RestakeDetailCardHeaderProps, + RestakeDetailCardItemProps, + RestakeDetailCardRootProps, +}; + +export { + RestakeDetailCardBody, + RestakeDetailCardHeader, + RestakeDetailCardItem, + RestakeDetailCardRoot, +}; + +export default RestakeDetailCard; diff --git a/apps/tangle-dapp/components/RestakeDetailCard/utils.ts b/apps/tangle-dapp/components/RestakeDetailCard/utils.ts new file mode 100644 index 0000000000..bcee727b14 --- /dev/null +++ b/apps/tangle-dapp/components/RestakeDetailCard/utils.ts @@ -0,0 +1,13 @@ +import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components/constants'; + +export function getDisplayValue(val?: string | number): string { + if (typeof val === 'string') { + return val; + } + + if (typeof val === 'number') { + return val.toLocaleString('en-US'); + } + + return EMPTY_VALUE_PLACEHOLDER; +} diff --git a/apps/tangle-dapp/utils/liquidStaking/getLsTangleNetwork.ts b/apps/tangle-dapp/utils/liquidStaking/getLsTangleNetwork.ts index 16990b37b7..cb0490b5c2 100644 --- a/apps/tangle-dapp/utils/liquidStaking/getLsTangleNetwork.ts +++ b/apps/tangle-dapp/utils/liquidStaking/getLsTangleNetwork.ts @@ -7,7 +7,7 @@ import { TANGLE_TESTNET_NATIVE_NETWORK, } from '@webb-tools/webb-ui-components/constants/networks'; -import { IS_PRODUCTION_ENV } from '../../constants/env'; +import { IS_PRODUCTION_ENV } from '../../constants'; import { LsNetworkId } from '../../constants/liquidStaking/types'; // TODO: Obtain the Tangle network directly from the adapter's `tangleNetwork` property instead of using this helper method. From b15228d062317f109a92d08cf59189b497cf4867 Mon Sep 17 00:00:00 2001 From: yurixander <101931215+yurixander@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:53:57 +0100 Subject: [PATCH 4/4] ci(tangle-dapp): Fix lint error --- apps/tangle-dapp/app/nomination/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tangle-dapp/app/nomination/page.tsx b/apps/tangle-dapp/app/nomination/page.tsx index d3f50cc0b1..1885bc0eb1 100644 --- a/apps/tangle-dapp/app/nomination/page.tsx +++ b/apps/tangle-dapp/app/nomination/page.tsx @@ -4,9 +4,9 @@ import { Metadata } from 'next'; import { OpenGraphPageImageUrl } from '../../constants/openGraph'; import { KeyStatsContainer } from '../../containers'; import HeaderChipsContainer from '../../containers/HeaderChipsContainer'; +import ActiveAndWaitingValidatorTables from '../../containers/nomination/ActiveAndWaitingValidatorTables'; import NominationsPayoutsContainer from '../../containers/nomination/NominationsPayoutsContainer'; import NominatorStatsContainer from '../../containers/nomination/NominatorStatsContainer'; -import ActiveAndWaitingValidatorTables from '../../containers/nomination/ActiveAndWaitingValidatorTables'; import createPageMetadata from '../../utils/createPageMetadata'; export const dynamic = 'force-static';