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

bugfix: re-introduce SpamFilter for TX (Nfts) #9206

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

mcayuelas-ledger
Copy link
Contributor

@mcayuelas-ledger mcayuelas-ledger commented Feb 12, 2025

βœ… Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • ...

πŸ“ Description

How it works :
Screenshot 2025-02-12 at 15 33 39

πŸ›οΈ We have a centralised hook in common for reuse in LLM and LLD

  • a hook to retrieve NFT_IN tx only
  • a hook to filter and hide spam (hiddenCollections object)
  • a hook to β€˜rebuild’ the data

ℹ️ Key points:

  • Add spamScore to collections and NFTs directly via our Backend
  • We take advantage of the network lib cache + the backend cache

πŸ€“ N.B: There are several network calls that go out because we need to process each NFT (collection) that we have in the operations
The calls go out as soon as the operations (which are recalculated to filter the operations on the NFTs) are ready, which is why we sometimes see 5-6 requests go out.

Demo :

Screen.Recording.2025-02-12.at.16.04.55.mov

And then added in hiddenCollections

Screen.Recording.2025-02-12.at.16.19.23.mov

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
web-tools ❌ Failed (Inspect) Feb 14, 2025 1:32pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 1:32pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 1:32pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 1:32pm

@live-github-bot live-github-bot bot added desktop Has changes in LLD ledgerjs Has changes in the ledgerjs open source libs labels Feb 12, 2025
@mcayuelas-ledger mcayuelas-ledger force-pushed the bugfix/spam-operations-replace branch from a4ec573 to 2119457 Compare February 12, 2025 14:37
@mcayuelas-ledger mcayuelas-ledger force-pushed the bugfix/spam-operations-replace branch from 2119457 to c691207 Compare February 12, 2025 15:08
@live-github-bot live-github-bot bot added the common Has changes in live-common label Feb 12, 2025
@mcayuelas-ledger mcayuelas-ledger marked this pull request as ready for review February 12, 2025 15:17
@mcayuelas-ledger mcayuelas-ledger requested a review from a team as a code owner February 12, 2025 15:17
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to handle batch like useNftMetadataBatch

Maybe it's not the best way to do but I just copied hook above and adapt it for Collection

libs/live-nft-react/src/hooks/useSpamTxFiltering.ts Outdated Show resolved Hide resolved
libs/live-nft-react/src/NftMetadataProvider.tsx Outdated Show resolved Hide resolved
libs/live-nft-react/src/NftMetadataProvider.tsx Outdated Show resolved Hide resolved
libs/live-nft-react/src/NftMetadataProvider.tsx Outdated Show resolved Hide resolved
libs/live-nft-react/src/hooks/useSpamTxFiltering.ts Outdated Show resolved Hide resolved
libs/live-nft-react/src/NftMetadataProvider.tsx Outdated Show resolved Hide resolved
)}
{groupedOperations?.sections?.map(
group =>
group.data.length > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

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

to avoid a condition on each and every group, i would use a filtered sections before.
Maybe not on the component level, i think here useOperationsList when you build the groupedOperations, make sure the sections in it (if you don't use) don't contain empty data group.

Copy link
Contributor

@themooneer themooneer left a comment

Choose a reason for hiding this comment

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

A very nice to review PR ! πŸ‘

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
34.7% Coverage on New Code (required β‰₯ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Has changes in live-common desktop Has changes in LLD ledgerjs Has changes in the ledgerjs open source libs translations Translation files have been touched
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants