Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(staking,extension,ui): StakePools Grid and List View integration, persistance adjustments [LW-9250, LW-9393, LW-9249, LW-9922] #904

Merged
merged 72 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
50118e4
feat(extension): adding sort and filter to browser extension
tommayeliog Feb 20, 2024
f629a5f
feat(staking,extension): embed BrowsePoolsPreferencesCard + refactor
przemyslaw-wlodek Feb 23, 2024
748685c
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Feb 28, 2024
a380100
feat(staking,extension): connect sorting logic with BrowsePoolsPrefer…
przemyslaw-wlodek Feb 28, 2024
5d0c396
feat(staking): hydrate browser pools state + hide ROS with .env
tommayeliog Feb 28, 2024
8a4d22d
feat(staking,extension,cardano): use ros instead of apy + unify usage…
przemyslaw-wlodek Feb 29, 2024
82d1989
feat(ui): make table header sortable column check optional
przemyslaw-wlodek Feb 29, 2024
9b4e599
test(cardano,extension): fix ros-related tests
przemyslaw-wlodek Mar 1, 2024
d601622
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 1, 2024
6e2ead0
fix(staking): useBrowsePools memoization + inf loop + TODOs
przemyslaw-wlodek Mar 1, 2024
fd7253a
work in progress
tommayeliog Mar 1, 2024
fb33c5f
work in progress
tommayeliog Mar 1, 2024
deb96fe
refactor(staking): remove redundant code + make it work
przemyslaw-wlodek Mar 1, 2024
5add91d
fix(staking): render numeric pool metrics correctly (StakePoolCard)
przemyslaw-wlodek Mar 4, 2024
990ae8b
refactor(staking,extension,ui,common): unify StakePool types, add for…
przemyslaw-wlodek Mar 5, 2024
5946ada
fix(staking): env vars % typo
tommayeliog Mar 5, 2024
57cd27f
fix(staking): remove ticker, saturation and ros from metric
tommayeliog Mar 5, 2024
7142a01
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 5, 2024
574fc07
chore(ui): suppress linter error
przemyslaw-wlodek Mar 5, 2024
2197642
fix(staking): stake pools grid breakpoints
przemyslaw-wlodek Mar 5, 2024
978970f
fix(staking): remove unnecessary network switch pools reset
przemyslaw-wlodek Mar 5, 2024
9851204
chore(staking): renames + remove leftovers (self-review)
przemyslaw-wlodek Mar 5, 2024
0e660b4
test(common): update format-number
przemyslaw-wlodek Mar 5, 2024
a109f66
chore(staking): adding a ticketnumber for TODO
tommayeliog Mar 6, 2024
3ac019e
fix(staking): prevent infinite loop in useBrowsePools (deps)
przemyslaw-wlodek Mar 6, 2024
6537bac
fix(staking): store hydration + refactor hooks
przemyslaw-wlodek Mar 6, 2024
8b8c9da
fix(staking): check for persisted data before hydration
przemyslaw-wlodek Mar 6, 2024
0fa3994
refactor(staking): remove unused poolView props from useQueryStakePoo…
przemyslaw-wlodek Mar 6, 2024
566df2a
fix(staking): check for non existing key in localStorage
tommayeliog Mar 6, 2024
b8682c2
refactor(staking): mark hydration as done when it is really done
przemyslaw-wlodek Mar 6, 2024
8544e4b
fix(staking): add missing condition during hydration
przemyslaw-wlodek Mar 6, 2024
bd7bf68
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 7, 2024
1194b31
fix(staking): update default sort + fix Search width at small screens
przemyslaw-wlodek Mar 7, 2024
7ee6b2d
chore(staking): add tickets for todos
tommayeliog Mar 7, 2024
a3ad9b6
fix(ui): change table.header sorting icon direction
tommayeliog Mar 7, 2024
3628457
feat(staking): make useQueryStakePools return detailed status + refactor
przemyslaw-wlodek Mar 8, 2024
c340de9
feat(staking): show Grid/List skeletons only when fetching (not pagin…
przemyslaw-wlodek Mar 8, 2024
6fb8d95
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 8, 2024
e72fcd1
feat(staking): add columnCount StakePoolGrid
tommayeliog Mar 11, 2024
ad18f12
test(extension): refactor e2e initial staking test (#932)
ljagiela Mar 8, 2024
74e1e42
chore(staking): add jira tickets for todos
przemyslaw-wlodek Mar 11, 2024
742e9af
feat(staking): add todo note for BrowsePools
tommayeliog Mar 11, 2024
ad784a9
chore(staking): add jira tickets for todos
przemyslaw-wlodek Mar 11, 2024
7483fe4
chore(staking): use StakePoolDetails type instead of deprecated Walle…
przemyslaw-wlodek Mar 11, 2024
6c86db0
fix(staking): number of items grid
tommayeliog Mar 12, 2024
2ebd903
chore(staking): remove console.debug
przemyslaw-wlodek Mar 12, 2024
074a8f3
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 12, 2024
8f82e77
fix(staking): export SortDirection as value (not type-only)
przemyslaw-wlodek Mar 13, 2024
69316dc
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 13, 2024
297756a
fix(staking): translation casing + remove unused type
przemyslaw-wlodek Mar 14, 2024
cc5173b
fix(staking): distinct pagination from fetch in legacy part
przemyslaw-wlodek Mar 14, 2024
4d20b9e
fix(staking): destructure searchFilters in stake-pool-search-slice
przemyslaw-wlodek Mar 14, 2024
8338f54
fix(staking): fix color for sort direction icon
tommayeliog Mar 15, 2024
3e1a7cb
fix(extension): fix zIndex for stickyTopNavigation
tommayeliog Mar 15, 2024
c2ce86f
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 15, 2024
59dedbe
fix(staking): remove custom UI sorting and exclude retired pools from…
przemyslaw-wlodek Mar 15, 2024
b154a8d
refactor(staking,extension): use SortOrder from SDK
przemyslaw-wlodek Mar 19, 2024
bdbc998
Merge remote-tracking branch 'origin/main' into feat/LW-9250-LW-9393-…
przemyslaw-wlodek Mar 19, 2024
324c7dc
Merge branch 'main' into feat/LW-9250-LW-9393-browse-pools-sorting
przemyslaw-wlodek Mar 19, 2024
81c217a
Merge branch 'main' into feat/LW-9250-LW-9393-browse-pools-sorting
tommayeliog Mar 20, 2024
c7ccddf
Merge branch 'main' into feat/LW-9250-LW-9393-browse-pools-sorting
tommayeliog Mar 21, 2024
391ecbe
feat(staking,ui): add new sorting icons and align stake pools browser
przemyslaw-wlodek Mar 21, 2024
85f5c9c
feat(staking): always sort ascending by default
przemyslaw-wlodek Mar 21, 2024
8b52fcc
feat(staking): add tooltip for browsePools sorting
tommayeliog Mar 21, 2024
bd08125
fix(staking): handle zero-values properly in mapStakePoolToDisplayData
przemyslaw-wlodek Mar 22, 2024
db59140
fix(staking): fix preferences card tooltips
tommayeliog Mar 22, 2024
21fdbaf
chore(ui): remove unused import
przemyslaw-wlodek Mar 22, 2024
b5b228e
fix(ui,staking): use custom zIndex for tooltip content (legacy side-p…
przemyslaw-wlodek Mar 22, 2024
c916093
fix(ui): remove testing leftover
przemyslaw-wlodek Mar 22, 2024
f5e7476
fix(staking): change saturation tooltip for preferencesCard
tommayeliog Mar 22, 2024
df783da
fix(staking): adding ROS tooltip PreferencesCard
tommayeliog Mar 22, 2024
7379be5
Merge branch 'main' into feat/LW-9250-LW-9393-browse-pools-sorting
tommayeliog Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ USE_MULTI_DELEGATION_STAKING_LEDGER=false
USE_MULTI_DELEGATION_STAKING_TREZOR=false
USE_MULTI_DELEGATION_STAKING_ACTIVITY=true
USE_MULTI_DELEGATION_STAKING_GRID_VIEW=false
USE_MULTI_DELEGATION_STAKING_FILTERS=false
USE_ROS_STAKING_COLUMN=false

USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT=false
Expand Down
1 change: 1 addition & 0 deletions apps/browser-extension-wallet/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ USE_POSTHOG_ANALYTICS_FOR_OPTED_OUT=false
USE_COMBINED_PASSWORD_NAME_STEP_COMPONENT=false
USE_MULTI_DELEGATION_STAKING_ACTIVITY=true
USE_MULTI_DELEGATION_STAKING_GRID_VIEW=false
USE_MULTI_DELEGATION_STAKING_FILTERS=false
USE_ROS_STAKING_COLUMN=false

# In App URLs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DelegationStore): stakePoolDetailsSelectorProps => {
cost,
hexId,
metadata: { description = '', name = '', ticker = '', homepage, ext } = {},
metrics: { apy, delegators, stake, saturation, blocksCreated } = {},
metrics: { ros, delegators, stake, saturation, blocksCreated } = {},
margin,
owners,
logo,
Expand Down Expand Up @@ -45,7 +45,7 @@ DelegationStore): stakePoolDetailsSelectorProps => {
: { number: '-' },
ticker,
status,
apy: apy && formatPercentages(apy),
ros: ros && formatPercentages(ros),
fee: Wallet.util.lovelacesToAdaString(cost.toString()),
contact: {
primary: homepage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface StakePool {
ticker?: string;
logo?: string;
retired?: boolean;
apy?: number | string;
ros?: number | string;
size?: string;
saturation?: number | string;
fee?: number | string;
Expand All @@ -43,7 +43,7 @@ export type stakePoolDetailsSelectorProps = {
activeStake: { number: string; unit?: string };
liveStake: { number: string; unit?: string };
ticker: string;
apy: number | string;
ros: number | string;
status: Wallet.Cardano.StakePool['status'];
fee: string;
contact: Wallet.Cardano.PoolContactData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@
"title": "Cost",
"tooltip": "The cost is not directly paid by the delegator; they are deducted from a pool's rewards, consisting of a fixed cost and a variable cost, which fund the pool's operational costs"
},
"apy": {
"ros": {
"title": "ROS",
"tooltip": "An estimation of the potential rewards you will earn per epoch if you delegate the intended amount of stake. The system looks at the pool's parameters and historical performance data to calculate potential rewards, assuming that the pool reaches optimal saturation."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const fetchStakePools =
startAt: skip,
limit: limit - skip + 1
},
sort
// @ts-expect-error TODO remove when ticker sort is available
vetalcore marked this conversation as resolved.
Show resolved Hide resolved
sort: sort && {
...sort,
...(sort.field === 'ticker' ? { field: 'name' } : {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...(sort.field === 'ticker' ? { field: 'name' } : {})
...(sort.field === SortField.ticker ? { field: SortField.name } : {})

if these are available of course*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. That's a valid comment, but we no longer have enum for this. We know how to transform enum to union-type but the other way around seems tricky or impossible (we haven't investigated this in-depth) and we prefer to reuse/extend the union from the SDK (for safety).

Copy link
Contributor

@vetalcore vetalcore Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wait till our discussion in slack is resolved

}
};
const { totalResultCount, pageResults } = await get().blockchainProvider.stakePoolProvider.queryStakePools(filters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ export const cardanoStakePoolMock: Wallet.StakePoolSearchResults = {
saturation: Percent(0.0512),
stake: undefined,
size: undefined,
apy: Percent(0.013),
ros: Percent(0.69),
lastRos: Percent(0.88)
},
Expand Down Expand Up @@ -564,21 +563,20 @@ export const cardanoStakePoolSelectedDetails = {
'stake_test1uq7g7kqeucnqfweqzgxk3dw34e8zg4swnc7nagysug2mm4cm77jrx'
],
saturation: '5.12',
apy: '1.30',
activeStake: {
number: '-'
},
liveStake: {
number: '-'
},
ros: '69.00',
status: 'active',
ticker: 'STTST',
blocks: '20',
pledge: '2000.00'
};

export const transformedStakePool = {
apy: '1.30',
cost: '2.00% + 6ADA',
description: 'This is the STTST description',
fee: '6.04',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
import { OutsideHandlesProvider, Staking } from '@lace/staking';
import React, { useCallback, useEffect } from 'react';
import { useAnalyticsContext, useCurrencyStore, useExternalLinkOpener, useTheme } from '@providers';
import { useBalances, useFetchCoinPrice, useLocalStorage } from '@hooks';
import { useDelegationStore } from '@src/features/delegation/stores';
import { usePassword, useSubmitingState } from '@views/browser/features/send-transaction';
import { Staking } from '@lace/staking';
import React, { useEffect } from 'react';
import { useTheme } from '@providers';
import { useFetchCoinPrice } from '@hooks';
import { useWalletStore } from '@stores';
import { compactNumberWithUnit } from '@utils/format-number';
import { useWalletActivities } from '@hooks/useWalletActivities';
import {
STAKING_BROWSER_PREFERENCES_LS_KEY,
MULTIDELEGATION_FIRST_VISIT_LS_KEY,
MULTIDELEGATION_FIRST_VISIT_SINCE_PORTFOLIO_PERSISTENCE_LS_KEY
} from '@utils/constants';
import { ActivityDetail } from '../../activity';
import { Drawer, DrawerNavigation } from '@lace/common';
import { useTranslation } from 'react-i18next';
import { withSignTxConfirmation } from '@lib/wallet-api-ui';
import { isMultidelegationSupportedByDevice } from '../helpers';

export const MultiDelegationStaking = (): JSX.Element => {
const { theme } = useTheme();
const { delegationTxBuilder, setDelegationTxBuilder, delegationTxFee, setDelegationTxFee } = useDelegationStore();
const openExternalLink = useExternalLinkOpener();
const password = usePassword();
const submittingState = useSubmitingState();
const { priceResult } = useFetchCoinPrice();
const { balance } = useBalances(priceResult?.cardano?.price);
const {
walletInfo,
walletType,
inMemoryWallet,
walletUI: { cardanoCoin },
stakePoolSearchResults,
stakePoolSearchResultsStatus,
fetchStakePools,
resetStakePools,
fetchNetworkInfo,
networkInfo,
blockchainProvider,
currentChain,
activityDetail,
resetActivityState
} = useWalletStore((state) => ({
const { blockchainProvider, currentChain, activityDetail, resetActivityState } = useWalletStore((state) => ({
walletType: state.walletType,
inMemoryWallet: state.inMemoryWallet,
walletUI: { cardanoCoin: state.walletUI.cardanoCoin },
Expand All @@ -58,85 +27,14 @@ export const MultiDelegationStaking = (): JSX.Element => {
resetActivityState: state.resetActivityState
}));
const { t } = useTranslation();
const sendAnalytics = useCallback(() => {
// TODO implement analytics for the new flow
const analytics = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
sendEvent: () => {}
};

// @ts-expect-error TODO implement analytics
analytics.sendEvent({
action: 'AnalyticsEventActions.CLICK_EVENT',
category: 'AnalyticsEventCategories.STAKING',
name: 'AnalyticsEventNames.Staking.STAKING_MULTI_DELEGATION_BROWSER'
});
}, []);
const { walletActivities, walletActivitiesStatus } = useWalletActivities({ sendAnalytics });
const { fiatCurrency } = useCurrencyStore();
const [multidelegationFirstVisit, { updateLocalStorage: setMultidelegationFirstVisit }] = useLocalStorage(
MULTIDELEGATION_FIRST_VISIT_LS_KEY,
true
);
const [
multidelegationFirstVisitSincePortfolioPersistence,
{ updateLocalStorage: setMultidelegationFirstVisitSincePortfolioPersistence }
] = useLocalStorage(MULTIDELEGATION_FIRST_VISIT_SINCE_PORTFOLIO_PERSISTENCE_LS_KEY, true);

const [stakingBrowserPreferencesPersistence, { updateLocalStorage: setStakingBrowserPreferencesPersistence }] =
useLocalStorage(STAKING_BROWSER_PREFERENCES_LS_KEY);

const walletAddress = walletInfo.addresses?.[0].address?.toString();
const analytics = useAnalyticsContext();

// Reset current transaction details and close drawer if network (blockchainProvider) has changed
useEffect(() => {
resetActivityState();
}, [resetActivityState, blockchainProvider]);

return (
<OutsideHandlesProvider
{...{
analytics,
stakingBrowserPreferencesPersistence,
setStakingBrowserPreferencesPersistence,
balancesBalance: balance,
delegationStoreSetDelegationTxBuilder: setDelegationTxBuilder,
delegationStoreDelegationTxBuilder: delegationTxBuilder,
delegationStoreSetDelegationTxFee: setDelegationTxFee,
delegationStoreDelegationTxFee: delegationTxFee,
fetchCoinPricePriceResult: priceResult,
openExternalLink,
walletManagerExecuteWithPassword: withSignTxConfirmation,
password,
submittingState,
walletStoreWalletType: walletType,
walletStoreInMemoryWallet: inMemoryWallet,
walletStoreWalletUICardanoCoin: cardanoCoin,
currencyStoreFiatCurrency: fiatCurrency,
walletStoreStakePoolSearchResults: stakePoolSearchResults,
walletStoreStakePoolSearchResultsStatus: stakePoolSearchResultsStatus,
walletStoreFetchStakePools: fetchStakePools,
walletStoreResetStakePools: resetStakePools,
walletStoreFetchNetworkInfo: fetchNetworkInfo,
walletStoreNetworkInfo: networkInfo,
walletStoreBlockchainProvider: blockchainProvider,
walletStoreWalletActivities: walletActivities,
walletStoreWalletActivitiesStatus: walletActivitiesStatus,
// TODO: LW-7575 make compactNumber reusable and not pass it here.
compactNumber: compactNumberWithUnit,
multidelegationFirstVisit,
triggerMultidelegationFirstVisit: () => setMultidelegationFirstVisit(false),
multidelegationFirstVisitSincePortfolioPersistence,
triggerMultidelegationFirstVisitSincePortfolioPersistence: () => {
setMultidelegationFirstVisit(false);
setMultidelegationFirstVisitSincePortfolioPersistence(false);
},
walletAddress,
currentChain,
isMultidelegationSupportedByDevice
}}
>
<>
<Staking currentChain={currentChain} theme={theme.name} />
{/*
Note: Mounting the browser-extension activity details drawer here is just a workaround.
Expand All @@ -159,6 +57,6 @@ export const MultiDelegationStaking = (): JSX.Element => {
>
{activityDetail && priceResult && <ActivityDetail price={priceResult} />}
</Drawer>
</OutsideHandlesProvider>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const StakePoolDetail = ({ popupView, setIsStaking }: stakePoolDetailProp
id,
hexId,
owners = [],
apy,
ros,
saturation,
activeStake,
liveStake,
Expand Down Expand Up @@ -109,7 +109,7 @@ export const StakePoolDetail = ({ popupView, setIsStaking }: stakePoolDetailProp
liveStake: t('cardano.stakePoolMetricsBrowser.liveStake'),
saturation: t('cardano.stakePoolMetricsBrowser.saturation'),
delegators: t('cardano.stakePoolMetricsBrowser.delegators'),
apy: t('cardano.stakePoolMetricsBrowser.ros'),
ros: t('cardano.stakePoolMetricsBrowser.ros'),
blocks: t('cardano.stakePoolMetricsBrowser.blocks'),
cost: t('cardano.stakePoolMetricsBrowser.cost'),
margin: t('cardano.stakePoolMetricsBrowser.margin'),
Expand All @@ -130,7 +130,7 @@ export const StakePoolDetail = ({ popupView, setIsStaking }: stakePoolDetailProp
{ t: metricsTranslations.activeStake, testId: 'active-stake', unit: activeStake.unit, value: activeStake.number },
{ t: metricsTranslations.liveStake, testId: 'live-stake', unit: liveStake.unit, value: liveStake.number },
{ t: metricsTranslations.delegators, testId: 'delegators', value: delegators || '-' },
{ t: metricsTranslations.apy, testId: 'apy', unit: '%', value: apy || '-' },
{ t: metricsTranslations.ros, testId: 'ros', unit: '%', value: ros || '-' },
{ t: metricsTranslations.blocks, testId: 'blocks', value: blocks },
{ t: metricsTranslations.cost, testId: 'cost', unit: formattedCost.unit, value: formattedCost.number },
{ t: metricsTranslations.pledge, testId: 'pledge', unit: formattedPledge.unit, value: formattedPledge.number },
Expand All @@ -145,7 +145,7 @@ export const StakePoolDetail = ({ popupView, setIsStaking }: stakePoolDetailProp
}, [
activeStake.number,
activeStake.unit,
apy,
ros,
blocks,
delegators,
formattedCost.number,
Expand All @@ -156,13 +156,13 @@ export const StakePoolDetail = ({ popupView, setIsStaking }: stakePoolDetailProp
liveStake.unit,
margin,
metricsTranslations.activeStake,
metricsTranslations.apy,
metricsTranslations.blocks,
metricsTranslations.cost,
metricsTranslations.delegators,
metricsTranslations.liveStake,
metricsTranslations.margin,
metricsTranslations.pledge,
metricsTranslations.ros,
metricsTranslations.saturation,
popupView,
saturation
Expand Down
Loading
Loading