-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'recovery-epic' into edit-recovery-flow
- Loading branch information
Showing
64 changed files
with
1,687 additions
and
1,185 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/components/dashboard/PendingTxs/PendingRecoveryListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Link from 'next/link' | ||
import { useMemo } from 'react' | ||
import { useRouter } from 'next/router' | ||
import { ChevronRight } from '@mui/icons-material' | ||
import { Box } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
import { RecoveryInfo } from '@/components/recovery/RecoveryInfo' | ||
import { RecoveryStatus } from '@/components/recovery/RecoveryStatus' | ||
import { RecoveryType } from '@/components/recovery/RecoveryType' | ||
import { AppRoutes } from '@/config/routes' | ||
import type { RecoveryQueueItem } from '@/components/recovery/RecoveryContext' | ||
|
||
import css from './styles.module.css' | ||
|
||
export function PendingRecoveryListItem({ transaction }: { transaction: RecoveryQueueItem }): ReactElement { | ||
const router = useRouter() | ||
const { isMalicious } = transaction | ||
|
||
const url = useMemo( | ||
() => ({ | ||
pathname: AppRoutes.transactions.queue, | ||
query: router.query, | ||
}), | ||
[router.query], | ||
) | ||
|
||
return ( | ||
<Link href={url} passHref> | ||
<Box className={css.container}> | ||
<Box gridArea="nonce" /> | ||
|
||
<Box gridArea="type"> | ||
<RecoveryType isMalicious={isMalicious} /> | ||
</Box> | ||
|
||
<Box gridArea="info"> | ||
<RecoveryInfo isMalicious={isMalicious} /> | ||
</Box> | ||
|
||
<Box gridArea="confirmations"> | ||
<RecoveryStatus recovery={transaction} /> | ||
</Box> | ||
|
||
<Box gridArea="action"> | ||
<ChevronRight color="border" /> | ||
</Box> | ||
</Box> | ||
</Link> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { BigNumber } from 'ethers' | ||
import { faker } from '@faker-js/faker' | ||
import { DetailedExecutionInfoType } from '@safe-global/safe-gateway-typescript-sdk' | ||
import type { MultisigExecutionInfo, Transaction } from '@safe-global/safe-gateway-typescript-sdk' | ||
|
||
import { safeInfoBuilder } from '@/tests/builders/safe' | ||
import { _getTransactionsToDisplay } from './PendingTxsList' | ||
import type { RecoveryQueueItem } from '@/components/recovery/RecoveryContext' | ||
|
||
describe('_getTransactionsToDisplay', () => { | ||
it('should return the recovery queue if it has more than or equal to MAX_TXS items', () => { | ||
const walletAddress = faker.finance.ethereumAddress() | ||
const safe = safeInfoBuilder().build() | ||
const recoveryQueue = [ | ||
{ timestamp: BigNumber.from(1) }, | ||
{ timestamp: BigNumber.from(2) }, | ||
{ timestamp: BigNumber.from(3) }, | ||
{ timestamp: BigNumber.from(4) }, | ||
{ timestamp: BigNumber.from(5) }, | ||
] as Array<RecoveryQueueItem> | ||
const queue = [] as Array<Transaction> | ||
|
||
const result = _getTransactionsToDisplay({ recoveryQueue, queue, walletAddress, safe }) | ||
expect(result).toStrictEqual(recoveryQueue.slice(0, 4)) | ||
}) | ||
|
||
it('should return the recovery queue followed by the actionable transactions from the queue', () => { | ||
const walletAddress = faker.finance.ethereumAddress() | ||
const safe = safeInfoBuilder().build() | ||
const recoveryQueue = [ | ||
{ timestamp: BigNumber.from(1) }, | ||
{ timestamp: BigNumber.from(2) }, | ||
{ timestamp: BigNumber.from(3) }, | ||
] as Array<RecoveryQueueItem> | ||
const actionableQueue = [ | ||
{ | ||
transaction: { id: '1' }, | ||
executionInfo: { | ||
type: DetailedExecutionInfoType.MULTISIG, | ||
missingSigners: [walletAddress], | ||
} as unknown as MultisigExecutionInfo, | ||
} as unknown as Transaction, | ||
{ | ||
transaction: { id: '2' }, | ||
executionInfo: { | ||
type: DetailedExecutionInfoType.MULTISIG, | ||
missingSigners: [walletAddress], | ||
} as unknown as MultisigExecutionInfo, | ||
} as unknown as Transaction, | ||
] | ||
|
||
const expected = [...recoveryQueue, actionableQueue[0]] | ||
const result = _getTransactionsToDisplay({ recoveryQueue, queue: actionableQueue, walletAddress, safe }) | ||
expect(result).toEqual(expected) | ||
}) | ||
|
||
it('should return the recovery queue followed by the transactions from the queue if there are no actionable transactions', () => { | ||
const walletAddress = faker.finance.ethereumAddress() | ||
const safe = safeInfoBuilder().build() | ||
const recoveryQueue = [ | ||
{ timestamp: BigNumber.from(1) }, | ||
{ timestamp: BigNumber.from(2) }, | ||
{ timestamp: BigNumber.from(3) }, | ||
] as Array<RecoveryQueueItem> | ||
const queue = [{ transaction: { id: '1' } }, { transaction: { id: '2' } }] as Array<Transaction> | ||
|
||
const expected = [...recoveryQueue, queue[0]] | ||
const result = _getTransactionsToDisplay({ recoveryQueue, queue, walletAddress, safe }) | ||
expect(result).toEqual(expected) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.