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

Fix: correct filtering of history for txs marked trusted and imitation [SW-100] #3907

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

jmealy
Copy link
Contributor

@jmealy jmealy commented Jul 4, 2024

What it solves

If there is a transaction marked with trusted: true and imitation: true, then it does not get filtered with the hide malicious toggle in the transaction history page.

How this PR fixes it

  • Specify the imitation query param for the /history endpoint, based on the value of the hide malicious toggle button on the transaction history page.
  • Also rename the hide malicious toggle in user settings to reflect the new name in the UI, and differentiate from the trusted flag on transactions.

Copy link

github-actions bot commented Jul 4, 2024

@jmealy jmealy requested a review from compojoom July 4, 2024 14:55
Copy link

github-actions bot commented Jul 4, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@jmealy jmealy removed the request for review from compojoom July 4, 2024 14:58
@jmealy jmealy marked this pull request as draft July 4, 2024 14:58
Copy link

github-actions bot commented Jul 4, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.02% (-0.02% 🔻)
11615/14699
🔴 Branches
58.64% (-0.16% 🔻)
2851/4862
🟡 Functions
65.94% (-0.18% 🔻)
1855/2813
🟢 Lines
80.41% (-0.03% 🔻)
10473/13025
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / index.tsx
89.29% 79.17% 100% 89.02%
🟢
... / hooks.ts
80% 63.16% 81.82% 80.61%
🟡
... / useTransactionType.ts
68.42% 40% 100% 69.44%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / helpers.ts
83.33% (-4.17% 🔻)
100%
80% (-5.71% 🔻)
83.33% (-2.38% 🔻)
🟢
... / formatNumber.ts
100%
92.86% (-1.59% 🔻)
100% 100%
🟡
... / utils.ts
75.26% (-0.5% 🔻)
65% (+5% 🔼)
76.19%
77.38% (-0.53% 🔻)
🔴
... / index.ts
43.48% (-6.52% 🔻)
0%
16.67% (-3.33% 🔻)
41.18% (-8.82% 🔻)
🔴
... / useTxHistory.ts
43.33% (-1.49% 🔻)
0% 0%
42.86% (-1.59% 🔻)
🟢
... / useWalletBalance.ts
84.62% (-7.69% 🔻)
100% 100%
83.33% (-8.33% 🔻)
🟢
... / index.tsx
88.89% (-1.39% 🔻)
71.05% (-11.21% 🔻)
60%
88.14% (-1.57% 🔻)
🔴
... / index.tsx
38.04% (-0.25% 🔻)
0% 0%
40.23% (-0.22% 🔻)

Test suite run success

1436 tests passing in 198 suites.

Report generated by 🧪jest coverage report action from f8e07b1

@jmealy jmealy changed the base branch from dev to release July 4, 2024 15:16
@jmealy jmealy changed the base branch from release to dev July 4, 2024 15:16
@jmealy jmealy changed the base branch from dev to release July 4, 2024 15:23
Base automatically changed from release to main July 10, 2024 10:21
@jmealy jmealy changed the base branch from main to dev July 17, 2024 08:50
Copy link

github-actions bot commented Jul 17, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@jmealy jmealy marked this pull request as ready for review July 17, 2024 08:51
@jmealy jmealy requested a review from schmanu July 17, 2024 08:52
Copy link

github-actions bot commented Jul 17, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1 MB (🟡 +10 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/transactions 73.43 KB (🟡 +1 B) 1.08 MB
/transactions/history 73.4 KB (🟡 +1 B) 1.08 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

const [data, error, loading] = useAsync<TransactionListPage>(
() => {
if (!safeLoaded) return
if (!safe.deployed) return Promise.resolve({ results: [] })

return getTxHistory(chainId, safeAddress, hasDefaultTokenlist && showOnlyTrustedTransactions)
return getTxHistory(chainId, safeAddress, hasDefaultTokenlist && hideSuspiciousTransactions)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return getTxHistory(chainId, safeAddress, hasDefaultTokenlist && hideSuspiciousTransactions)
return getTxHistory(chainId, safeAddress, hideSuspiciousTransactions)

The default token list is not necessary for the new imitation detection.

const hasDefaultTokenlist = useHasFeature(FEATURES.DEFAULT_TOKENLIST)
const onlyTrusted = (hasDefaultTokenlist && showOnlyTrustedTransactions) || false
const hideSuspicious = (hasDefaultTokenlist && hideSuspiciousTransactions) || false
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const hideSuspicious = (hasDefaultTokenlist && hideSuspiciousTransactions) || false
const hideSuspicious = (hideSuspiciousTransactions) || false

Same here

@@ -18,13 +18,15 @@ export const getTxDetails = memoize(
(id: string, chainId: string) => `${chainId}-${id}`,
)

export const getTxHistory = (chainId: string, safeAddress: string, trusted = false, pageUrl?: string) => {
export const getTxHistory = (chainId: string, safeAddress: string, hideSuspicious = false, pageUrl?: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

We should maybe have two flags for trusted and imitation that we pass here.

The trusted filtering requires token lists to be available. But imitations don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created separate flags here and also in fetchFilteredTxHistory

Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@jmealy jmealy requested a review from schmanu July 23, 2024 11:56
@jmealy jmealy changed the title Fix: correct filtering of history for txs marked trusted and imitation Fix: correct filtering of history for txs marked trusted and imitation [SW-100] Jul 23, 2024
Copy link

@jmealy jmealy marked this pull request as draft July 23, 2024 15:16
Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@jmealy
Copy link
Contributor Author

jmealy commented Jul 29, 2024

I noticed an issue with the filtering, but it is pre-existing so I created a separate ticket for it: #4005

@jmealy jmealy marked this pull request as ready for review July 29, 2024 14:17
@liliya-soroka
Copy link
Member

Verified

@jmealy jmealy merged commit 15b70d1 into dev Aug 9, 2024
16 of 19 checks passed
@jmealy jmealy deleted the imitation-filter branch August 9, 2024 12:15
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants