From 983421751e3ecbd059a778da7572075df9a92d3f Mon Sep 17 00:00:00 2001
From: yurixander <101931215+yurixander@users.noreply.github.com>
Date: Sat, 7 Sep 2024 09:58:14 -0400
Subject: [PATCH] feat(tangle-dapp): Create `useLsPools` hook
---
apps/tangle-dapp/app/liquid-staking/page.tsx | 6 +-
.../components/LiquidStaking/AddressLink.tsx | 4 +-
.../LiquidStaking/VaultsAndAssetsTable.tsx | 4 +-
.../stakeAndUnstake/FeeDetailItem.tsx | 18 +--
.../stakeAndUnstake/LsFeeWarning.tsx | 8 +-
.../stakeAndUnstake/SelectTokenModal.tsx | 8 +-
.../stakeAndUnstake/TotalDetailItem.tsx | 20 +--
...eLsFeePermill.ts => useLsFeePercentage.ts} | 12 +-
.../constants/liquidStaking/types.ts | 16 +--
apps/tangle-dapp/constants/networks.ts | 9 +-
...rachainPoolsTable.tsx => LsPoolsTable.tsx} | 127 ++++++++----------
.../data/liquidStaking/adapters/polkadot.tsx | 5 +-
.../data/liquidStaking/useLsPools.ts | 107 +++++++++++++++
.../data/liquidStaking/useParachainLsFees.ts | 8 +-
apps/tangle-dapp/hooks/useApi.ts | 27 +++-
apps/tangle-dapp/hooks/useApiRx.ts | 22 ++-
apps/tangle-dapp/hooks/useNetworkFeatures.ts | 4 +-
apps/tangle-dapp/types/index.ts | 1 +
apps/tangle-dapp/types/utils.ts | 7 +-
.../utils/assertAnySubstrateAddress.ts | 14 --
.../utils/assertSubstrateAddress.ts | 12 +-
.../utils/isAnySubstrateAddress.ts | 4 +-
apps/tangle-dapp/utils/permillToPercentage.ts | 2 +-
apps/tangle-dapp/utils/polkadot/identity.ts | 5 +-
.../utils/scaleAmountByPercentage.ts | 14 ++
.../tangle-dapp/utils/scaleAmountByPermill.ts | 14 --
libs/dapp-config/src/constants/tangle.ts | 4 +-
.../src/constants/networks.ts | 10 +-
28 files changed, 303 insertions(+), 189 deletions(-)
rename apps/tangle-dapp/components/LiquidStaking/stakeAndUnstake/{useLsFeePermill.ts => useLsFeePercentage.ts} (90%)
rename apps/tangle-dapp/containers/{ParachainPoolsTable.tsx => LsPoolsTable.tsx} (71%)
create mode 100644 apps/tangle-dapp/data/liquidStaking/useLsPools.ts
delete mode 100644 apps/tangle-dapp/utils/assertAnySubstrateAddress.ts
create mode 100644 apps/tangle-dapp/utils/scaleAmountByPercentage.ts
delete mode 100644 apps/tangle-dapp/utils/scaleAmountByPermill.ts
diff --git a/apps/tangle-dapp/app/liquid-staking/page.tsx b/apps/tangle-dapp/app/liquid-staking/page.tsx
index 8d0dfca38..d6812958a 100644
--- a/apps/tangle-dapp/app/liquid-staking/page.tsx
+++ b/apps/tangle-dapp/app/liquid-staking/page.tsx
@@ -7,7 +7,7 @@ import LsStakeCard from '../../components/LiquidStaking/stakeAndUnstake/LsStakeC
import LsUnstakeCard from '../../components/LiquidStaking/stakeAndUnstake/LsUnstakeCard';
import UnstakeRequestsTable from '../../components/LiquidStaking/unstakeRequestsTable/UnstakeRequestsTable';
import { LsSearchParamKey } from '../../constants/liquidStaking/types';
-import ParachainPoolsTable from '../../containers/ParachainPoolsTable';
+import LsPoolsTable from '../../containers/LsPoolsTable';
import { useLsStore } from '../../data/liquidStaking/useLsStore';
import useSearchParamState from '../../hooks/useSearchParamState';
import isLsParachainChainId from '../../utils/liquidStaking/isLsParachainChainId';
@@ -29,7 +29,7 @@ const LiquidStakingTokenPage: FC = () => {
});
const { selectedProtocolId } = useLsStore();
-
+
const isParachainChain = isLsParachainChainId(selectedProtocolId);
return (
@@ -54,7 +54,7 @@ const LiquidStakingTokenPage: FC = () => {
{isStaking ? (
isParachainChain ? (
-
+
) : (
)
diff --git a/apps/tangle-dapp/components/LiquidStaking/AddressLink.tsx b/apps/tangle-dapp/components/LiquidStaking/AddressLink.tsx
index 389a2918b..b899694aa 100644
--- a/apps/tangle-dapp/components/LiquidStaking/AddressLink.tsx
+++ b/apps/tangle-dapp/components/LiquidStaking/AddressLink.tsx
@@ -3,10 +3,10 @@ import { ExternalLinkLine } from '@webb-tools/icons';
import { shortenString, Typography } from '@webb-tools/webb-ui-components';
import { FC, useCallback } from 'react';
-import { AnySubstrateAddress } from '../../types/utils';
+import { SubstrateAddress } from '../../types/utils';
export type AddressLinkProps = {
- address: AnySubstrateAddress | HexString;
+ address: SubstrateAddress | HexString;
};
const AddressLink: FC
= ({ address }) => {
diff --git a/apps/tangle-dapp/components/LiquidStaking/VaultsAndAssetsTable.tsx b/apps/tangle-dapp/components/LiquidStaking/VaultsAndAssetsTable.tsx
index 1b7caf8c1..acdfa4e78 100644
--- a/apps/tangle-dapp/components/LiquidStaking/VaultsAndAssetsTable.tsx
+++ b/apps/tangle-dapp/components/LiquidStaking/VaultsAndAssetsTable.tsx
@@ -14,6 +14,7 @@ import { twMerge } from 'tailwind-merge';
import useVaults from '../../app/liquid-staking/useVaults';
import StatItem from '../../components/StatItem';
import TableCellWrapper from '../../components/tables/TableCellWrapper';
+import { PagePath } from '../../types';
import { Asset, Vault } from '../../types/liquidStaking';
import LsTokenIcon from '../LsTokenIcon';
@@ -80,8 +81,7 @@ const vaultColumns = [
cell: ({ row }) => (
- {/* TODO: add proper href */}
-
+