Skip to content

🦺 server: filter notifications to known tokens only#974

Open
aguxez wants to merge 1 commit intomainfrom
filter-notifications
Open

🦺 server: filter notifications to known tokens only#974
aguxez wants to merge 1 commit intomainfrom
filter-notifications

Conversation

@aguxez
Copy link
Copy Markdown
Contributor

@aguxez aguxez commented Apr 24, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Notifications now only alert for recognized tokens using a cached token list; failures in token verification still allow notifications.
  • Tests

    • Added comprehensive tests for token-filtering, cache behavior, multi-chain scope, and error/fallback scenarios.
  • Chores

    • Extended spell-check dictionary and added release metadata for the server package.

@aguxez aguxez force-pushed the filter-notifications branch from 391e906 to b5ee87a Compare April 24, 2026 11:28
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: 8e731f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@aguxez has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 16 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7742687a-65b8-4aca-aed3-e6eb6c6c2165

📥 Commits

Reviewing files that changed from the base of the PR and between 53dadc1 and 8e731f9.

📒 Files selected for processing (4)
  • .changeset/sharp-sails-guess.md
  • cspell.json
  • server/hooks/activity.ts
  • server/test/hooks/activity.test.ts

Walkthrough

Adds Redis-cached LiFi token lookups to activity hook notification logic: notifications for incoming transfers are sent only if the asset is in marketsByAsset or known via per-chain LiFi token cache (fetch/cache on miss). Tests and Sentry error capturing updated accordingly.

Changes

Cohort / File(s) Summary
Changeset & Spelling
/.changeset/sharp-sails-guess.md, cspell.json
Adds a changeset entry for @exactly/server (patch) and extends cspell allowlist with sadd, scard, sismember.
Token Filtering & Notification Logic
server/hooks/activity.ts
Adds isKnownToken using Redis per-chain sets (lifi:tokens:${chainId}) with SISMEMBER+SCARD pipeline; on cache miss fetches https://li.quest/v1/tokens?chains=${chainId} (5s timeout), repopulates Redis with EXPIRE, and conditions push notifications on marketsByAsset or known-token. Sentry captureException calls include { level: "error" }.
Tests
server/test/hooks/activity.test.ts
Adds Redis cleanup, mockLifiTokens, tighter Sentry assertions, and a "lifi token filter" suite covering cache-hit/miss, suppression, fail-open behaviors, pipeline failures, empty responses, and chain isolation.

Sequence Diagram

sequenceDiagram
    participant Activity as Activity Hook
    participant Redis as Redis Cache
    participant LiFi as LiFi API
    participant Sentry as Sentry
    participant Notif as Notification Service

    Activity->>Redis: SISMEMBER & SCARD (lifi:tokens:chainId)
    alt Cache Hit
        Redis-->>Activity: Token known? / set size
    else Cache Miss
        Activity->>LiFi: GET /v1/tokens?chains=chainId (5s timeout)
        alt Success
            LiFi-->>Activity: Token list
            Activity->>Redis: DEL, SADD parsed addresses, EXPIRE 3600
            Redis-->>Activity: OK
        else Failure
            LiFi-->>Activity: Error
            Activity->>Sentry: captureException(error, { level: "error" })
            Activity-->>Activity: assume token known (fail-open)
        end
    end

    Activity-->>Activity: determine knownToken (marketsByAsset || isKnownToken)
    alt Token Known
        Activity->>Notif: sendPushNotification(...)
    else Token Unknown
        Activity-->>Notif: suppress notification
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • nfmelendez
  • cruzdanilo
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately describes the main change: filtering notifications to only known tokens, which is the core modification across activity.ts and its tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch filter-notifications

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.37%. Comparing base (a43a2e5) to head (8e731f9).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/hooks/activity.ts 93.61% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #974      +/-   ##
==========================================
+ Coverage   72.02%   73.37%   +1.34%     
==========================================
  Files         229      229              
  Lines        8358     9059     +701     
  Branches     2692     3003     +311     
==========================================
+ Hits         6020     6647     +627     
- Misses       2106     2155      +49     
- Partials      232      257      +25     
Flag Coverage Δ
e2e 73.37% <93.61%> (+21.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aguxez aguxez force-pushed the filter-notifications branch 2 times, most recently from ecdf4f2 to 4d6172b Compare April 24, 2026 14:04
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
server/hooks/activity.ts (1)

143-143: ⚠️ Potential issue | 🟠 Major

Blocking webhook response on a per-transfer LiFi fetch.

await isKnownToken(chain.id, underlying) runs serially inside the for (const ... of transfers) loop before c.json({}) returns. On cache miss, this adds up to 5s (plus Redis RTTs) per unknown-token transfer, serialized across transfers in the payload. Alchemy may retry slow webhooks, which can amplify downstream work (poking, autoCredit, duplicate sends).

Consider resolving the known-token check off the response path — e.g. kick off the LiFi/Redis checks in parallel and gate only the sendPushNotification(...) call on an already-resolved decision, so the handler acks quickly regardless of LiFi latency.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3560abdd-a0de-493c-8582-db8f20162cb6

📥 Commits

Reviewing files that changed from the base of the PR and between b5ee87a and 4d6172b.

📒 Files selected for processing (4)
  • .changeset/sharp-sails-guess.md
  • cspell.json
  • server/hooks/activity.ts
  • server/test/hooks/activity.test.ts

@aguxez aguxez marked this pull request as ready for review April 27, 2026 08:03
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@aguxez aguxez force-pushed the filter-notifications branch from 4d6172b to 53dadc1 Compare April 27, 2026 11:27
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53dadc1439

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/hooks/activity.ts
coderabbitai[bot]

This comment was marked as resolved.

@aguxez aguxez force-pushed the filter-notifications branch from 53dadc1 to 7d31ae1 Compare April 27, 2026 12:07
@aguxez aguxez force-pushed the filter-notifications branch from 7d31ae1 to 8e731f9 Compare April 27, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant