Skip to content

Commit

Permalink
fix: hide suspicious transactions by default (#4425)
Browse files Browse the repository at this point in the history
* Hide suspicious transactions by default

* Only default if `undefined`

* Update E2E test

* Fix E2E
  • Loading branch information
iamacook authored Oct 25, 2024
1 parent 9620abd commit 1b1f128
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const addressItem = '[data-testid="address-item"]'
const radioSelector = 'div[role="radiogroup"]'
const rejectTxBtn = '[data-testid="reject-btn"]'
const deleteTxModalBtn = '[data-testid="delete-tx-btn"]'
const toggleUntrustedBtn = '[data-testid="toggle-untrusted"]'

const viewTransactionBtn = 'View transaction'
const transactionDetailsTitle = 'Transaction details'
Expand Down Expand Up @@ -607,3 +608,7 @@ export function verifyBulkExecuteBtnIsDisabled() {
cy.get('button').contains(bulkExecuteBtnStr).trigger('mouseover', { force: true })
cy.contains(disabledBultExecuteBtnTooltip).should('exist')
}

export function toggleUntrustedTxs() {
cy.get(toggleUntrustedBtn).click()
}
2 changes: 2 additions & 0 deletions cypress/e2e/smoke/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('[SMOKE] Tx history tests', () => {
})

it('[SMOKE] Verify summary for untrusted token', () => {
createTx.toggleUntrustedTxs()
createTx.verifySummaryByName(
typeUntrustedToken.summaryTitle,
typeUntrustedToken.summaryTxInfo,
Expand All @@ -85,6 +86,7 @@ describe('[SMOKE] Tx history tests', () => {
})

it('[SMOKE] Verify that copying sender address of untrusted token shows warning popup', () => {
createTx.toggleUntrustedTxs()
createTx.clickOnTransactionItemByName(typeUntrustedToken.summaryTitle, typeUntrustedToken.summaryTxInfo)
createTx.clickOnCopyBtn(0)
createTx.verifyWarningModalVisible()
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/loadables/useLoadTxHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const useLoadTxHistory = (): AsyncResult<TransactionListPage> => {
const { chainId, txHistoryTag } = safe
const { hideSuspiciousTransactions } = useAppSelector(selectSettings)
const hasDefaultTokenlist = useHasFeature(FEATURES.DEFAULT_TOKENLIST)
const hideUntrustedTxs = (hasDefaultTokenlist && hideSuspiciousTransactions) || false
const hideImitationTxs = hideSuspiciousTransactions || false
const hideUntrustedTxs = (hasDefaultTokenlist && hideSuspiciousTransactions) ?? true
const hideImitationTxs = hideSuspiciousTransactions ?? true

// Re-fetch when chainId, address, hideSuspiciousTransactions, or txHistoryTag changes
const [data, error, loading] = useAsync<TransactionListPage>(
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTxHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const useTxHistory = (
const [filter] = useTxFilter()
const { hideSuspiciousTransactions } = useAppSelector(selectSettings)
const hasDefaultTokenlist = useHasFeature(FEATURES.DEFAULT_TOKENLIST)
const hideUntrustedTxs = (hasDefaultTokenlist && hideSuspiciousTransactions) || false
const hideImitationTxs = hideSuspiciousTransactions || false
const hideUntrustedTxs = (hasDefaultTokenlist && hideSuspiciousTransactions) ?? true
const hideImitationTxs = hideSuspiciousTransactions ?? true

const {
safe: { chainId },
Expand Down
2 changes: 1 addition & 1 deletion src/store/settingsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const initialState: SettingsState = {

hiddenTokens: {},

hideSuspiciousTransactions: false,
hideSuspiciousTransactions: true,

shortName: {
copy: true,
Expand Down

0 comments on commit 1b1f128

Please sign in to comment.