From a32b713beb1a03e138001d61bd37db7255da07b6 Mon Sep 17 00:00:00 2001 From: iamacook Date: Tue, 21 Nov 2023 12:29:32 +0100 Subject: [PATCH] fix: add comment + rename selector --- src/components/dashboard/RecoveryInProgress/index.tsx | 4 ++-- src/components/recovery/RecoveryList/index.tsx | 4 ++-- src/store/__tests__/recoverySlice.test.ts | 6 +++--- src/store/recoverySlice.ts | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/dashboard/RecoveryInProgress/index.tsx b/src/components/dashboard/RecoveryInProgress/index.tsx index c17548bc85..90972699ec 100644 --- a/src/components/dashboard/RecoveryInProgress/index.tsx +++ b/src/components/dashboard/RecoveryInProgress/index.tsx @@ -8,7 +8,7 @@ import RecoveryPending from '@/public/images/common/recovery-pending.svg' import ExternalLink from '@/components/common/ExternalLink' import { useHasFeature } from '@/hooks/useChains' import { FEATURES } from '@/utils/chains' -import { selectAllRecoveryQueues } from '@/store/recoverySlice' +import { selectRecoveryQueues } from '@/store/recoverySlice' import madProps from '@/utils/mad-props' import { Countdown } from '@/components/common/Countdown' import { useRecoveryTxState } from '@/hooks/useRecoveryTxState' @@ -82,7 +82,7 @@ function _RecoveryInProgressWidget({ nextTx }: { nextTx: RecoveryQueueItem }): R // Appease React TypeScript warnings const _useTimestamp = () => useClock(60_000) // Countdown does not display const _useSupportsRecovery = () => useHasFeature(FEATURES.RECOVERY) -const _useQueuedRecoveryTxs = () => useAppSelector(selectAllRecoveryQueues) +const _useQueuedRecoveryTxs = () => useAppSelector(selectRecoveryQueues) export const RecoveryInProgress = madProps(_RecoveryInProgress, { timestamp: _useTimestamp, diff --git a/src/components/recovery/RecoveryList/index.tsx b/src/components/recovery/RecoveryList/index.tsx index c293d2e418..99be7c464f 100644 --- a/src/components/recovery/RecoveryList/index.tsx +++ b/src/components/recovery/RecoveryList/index.tsx @@ -2,13 +2,13 @@ import type { ReactElement } from 'react' import { TxListGrid } from '@/components/transactions/TxList' import { RecoveryListItem } from '@/components/recovery/RecoveryListItem' -import { selectAllRecoveryQueues } from '@/store/recoverySlice' +import { selectRecoveryQueues } from '@/store/recoverySlice' import { useAppSelector } from '@/store' import labelCss from '@/components/transactions/GroupLabel/styles.module.css' export function RecoveryList(): ReactElement | null { - const queue = useAppSelector(selectAllRecoveryQueues) + const queue = useAppSelector(selectRecoveryQueues) if (queue.length === 0) { return null diff --git a/src/store/__tests__/recoverySlice.test.ts b/src/store/__tests__/recoverySlice.test.ts index 94cb0f6dc2..bd76576d1b 100644 --- a/src/store/__tests__/recoverySlice.test.ts +++ b/src/store/__tests__/recoverySlice.test.ts @@ -1,7 +1,7 @@ import { BigNumber } from 'ethers' import { faker } from '@faker-js/faker' -import { selectDelayModifierByGuardian, selectAllRecoveryQueues, selectDelayModifierByTxHash } from '../recoverySlice' +import { selectDelayModifierByGuardian, selectRecoveryQueues, selectDelayModifierByTxHash } from '../recoverySlice' import type { RecoveryState } from '../recoverySlice' import type { RootState } from '..' @@ -34,7 +34,7 @@ describe('recoverySlice', () => { }) }) - describe('selectAllRecoveryQueues', () => { + describe('selectRecoveryQueues', () => { it('should return all recovery queues sorted by timestamp', () => { const delayModifier1 = { queue: [{ timestamp: BigNumber.from(1) }, { timestamp: BigNumber.from(3) }], @@ -51,7 +51,7 @@ describe('recoverySlice', () => { const data = [delayModifier1, delayModifier2, delayModifier3] expect( - selectAllRecoveryQueues({ + selectRecoveryQueues({ recovery: { data }, } as unknown as RootState), ).toStrictEqual([ diff --git a/src/store/recoverySlice.ts b/src/store/recoverySlice.ts index 13e614d3ac..210e710da7 100644 --- a/src/store/recoverySlice.ts +++ b/src/store/recoverySlice.ts @@ -14,6 +14,7 @@ export type RecoveryQueueItem = TransactionAddedEvent & { executor: string } +// State of current Safe, populated on load export type RecoveryState = Array<{ address: string guardians: Array @@ -39,7 +40,7 @@ export const selectDelayModifierByGuardian = createSelector( }, ) -export const selectAllRecoveryQueues = createSelector(selectRecovery, (recovery) => { +export const selectRecoveryQueues = createSelector(selectRecovery, (recovery) => { return recovery.flatMap(({ queue }) => queue).sort((a, b) => a.timestamp.sub(b.timestamp).toNumber()) })