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

Align screen & geoblock compliance endpoints #1829

Merged
merged 3 commits into from
Jul 2, 2024
Merged

Conversation

dydxwill
Copy link
Contributor

@dydxwill dydxwill commented Jul 1, 2024

Changelist

In GET /screen endpoint:
Only update the compliance_status table if the status is not CLOSE_ONLY/BLOCKED.
If there is an existing compliance_status row for an address, return it rather than COMPLIANT status.

Test Plan

unit tested

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Tests

    • Added test cases for handling compliance statuses based on address restrictions, including scenarios for restricted addresses and existing compliance data.
  • Refactor

    • Refined logic for compliance status retrieval and updates in the ComplianceV2Controller class, enhancing data handling and return structures.

These changes improve the accuracy and robustness of compliance status updates and retrieval processes.

Copy link
Contributor

coderabbitai bot commented Jul 1, 2024

Walkthrough

This update primarily enhances the compliance handling logic in the ComplianceV2Controller. It introduces new test cases for compliance statuses associated with restricted and non-restricted dydx addresses and refines the conditions for data retrieval and updates in the controller.

Changes

File/Path Summary
.../__tests__/controllers/api/v4/compliance-v2-controller.test.ts Added tests for scenarios involving dydx addresses with different compliance statuses, including CLOSE_ONLY and non-restricted addresses with existing data.
.../src/controllers/api/v4/compliance-v2-controller.ts Adjusted logic for compliance status retrieval and updates, including additional conditions and refined return statement structures.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ComplianceV2Controller
    participant ComplianceStatusTable

    Client->>ComplianceV2Controller: Request compliance status for address
    alt Address is restricted and has CLOSE_ONLY status
        ComplianceV2Controller->>ComplianceStatusTable: Fetch compliance status
        ComplianceStatusTable-->>ComplianceV2Controller: Return compliance status (CLOSE_ONLY)
        ComplianceV2Controller-->>Client: Return compliance status (CLOSE_ONLY)
    else Address is not restricted
        ComplianceV2Controller->>ComplianceStatusTable: Fetch compliance status
        ComplianceStatusTable-->>ComplianceV2Controller: Return compliance status (e.g., FIRST_STRIKE)
        ComplianceV2Controller-->>Client: Return existing compliance status
    end
Loading

Poem

Amidst the code, a change so grand,
Compliance checks through each demand.
With CLOSE_ONLY or `FIRST_STRIKE’ fate,
Ensuring all the data's straight.
A line of tests, a logic refined,
In every address, the truth we find. 🌟🐇


Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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.

Actionable comments posted: 3

Outside diff range and nitpick comments (3)
indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts (3)

Line range hint 64-64: Remove invalid use of decorators.

Decorators are only valid on class declarations, class expressions, and class methods. This usage is invalid.

- @Route('compliance')

Line range hint 78-82: Omit the unnecessary else clause.

This else clause can be omitted because the previous branch breaks early.

- } else {
-   return {
-     status: ComplianceStatus.COMPLIANT,
-   };
- }
+ return {
+   status: ComplianceStatus.COMPLIANT,
+ };

Line range hint 83-129: Omit the unnecessary else clause.

This else clause can be omitted because the previous branch breaks early.

- } else {
-   return {
-     status: complianceStatusFromDatabase!.status,
-     reason: complianceStatusFromDatabase!.reason,
-     updatedAt: complianceStatusFromDatabase!.updatedAt,
-   };
- }
+ return {
+   status: complianceStatusFromDatabase!.status,
+   reason: complianceStatusFromDatabase!.reason,
+   updatedAt: complianceStatusFromDatabase!.updatedAt,
+ };
Tools
Biome

[error] 117-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-127: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c06db6f and 8d04b87.

Files selected for processing (3)
  • indexer/services/comlink/tests/controllers/api/v4/compliance-v2-controller.test.ts (2 hunks)
  • indexer/services/comlink/public/api-documentation.md (121 hunks)
  • indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts (2 hunks)
Files not summarized due to errors (1)
  • indexer/services/comlink/public/api-documentation.md: Error: Message exceeds token limit
Files not reviewed due to errors (1)
  • indexer/services/comlink/tests/controllers/api/v4/compliance-v2-controller.test.ts (no review received)
Additional context used
Learnings (1)
indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts (1)
Learnt from: vincentwschau
PR: dydxprotocol/v4-chain#1728
File: indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts:327-394
Timestamp: 2024-06-19T15:01:43.117Z
Learning: User vincentwschau acknowledged the correction suggestion about renaming the function `upsertComplicanceStatus` to `upsertComplianceStatus` with a thumbs-up emoji, indicating agreement or approval.
Biome
indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts

[error] 64-64: Decorators are not valid here.

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

(parse)


[error] 78-82: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 83-129: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 117-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-127: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 396-402: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

LanguageTool
indexer/services/comlink/public/api-documentation.md

[misspelling] ~2679-~2679: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schemaperpetualpositionstatus"> </a...

(EN_A_VS_AN)


[misspelling] ~2680-~2680: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schema_PerpetualPositionStatus"> <...

(EN_A_VS_AN)


[misspelling] ~2705-~2705: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...onSide <a id="to...

(EN_A_VS_AN)


[misspelling] ~2706-~2706: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."> <a id="tocsp...

(EN_A_VS_AN)


[misspelling] ~2730-~2730: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...IsoString <a id="tocSi...

(EN_A_VS_AN)


[misspelling] ~2731-~2731: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ing"> <a id="tocsisos...

(EN_A_VS_AN)


[misspelling] ~2748-~2748: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...maperpetualpositionresponseobject"> <a id="schema_PerpetualPositionResponseObj...

(EN_A_VS_AN)


[misspelling] ~2749-~2749: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a_PerpetualPositionResponseObject"> <a id="tocSperpetualpositionresponseobject...

(EN_A_VS_AN)


[misspelling] ~2798-~2798: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schemaperpetualpositionsmap"> ...

(EN_A_VS_AN)


[misspelling] ~2799-~2799: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schema_PerpetualPositionsMap"> <a ...

(EN_A_VS_AN)


[misspelling] ~2853-~2853: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...schemaassetpositionresponseobject"> <a id="schema_AssetPositionResponseObject"...

(EN_A_VS_AN)


[misspelling] ~2854-~2854: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...chema_AssetPositionResponseObject"> </...

(EN_A_VS_AN)


[misspelling] ~2881-~2881: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...p <a i...

(EN_A_VS_AN)


[misspelling] ~2882-~2882: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...> <a id="...

(EN_A_VS_AN)


[misspelling] ~2914-~2914: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schemasubaccountresponseobject"> </...

(EN_A_VS_AN)


[misspelling] ~2915-~2915: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...="schema_SubaccountResponseObject"> ...

(EN_A_VS_AN)


[misspelling] ~3002-~3002: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...nse <a id=...

(EN_A_VS_AN)


[misspelling] ~3003-~3003: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: .../a> <a id="to...

(EN_A_VS_AN)


[misspelling] ~3088-~3088: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schemaparentsubaccountresponse"> </...

(EN_A_VS_AN)


[misspelling] ~3089-~3089: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...="schema_ParentSubaccountResponse"> ...

(EN_A_VS_AN)


[misspelling] ~3180-~3180: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schemaassetpositionresponse"> ...

(EN_A_VS_AN)


[misspelling] ~3181-~3181: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schema_AssetPositionResponse"> <a ...

(EN_A_VS_AN)


[misspelling] ~3208-~3208: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...on <a id...

(EN_A_VS_AN)


[misspelling] ~3209-~3209: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a> <a id="t...

(EN_A_VS_AN)


[misspelling] ~3238-~3238: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <...

(EN_A_VS_AN)


[misspelling] ~3239-~3239: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schema_CandleResponseObject"> <a i...

(EN_A_VS_AN)


[misspelling] ~3280-~3280: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...onse <a id="...

(EN_A_VS_AN)


[misspelling] ~3281-~3281: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id="toc...

(EN_A_VS_AN)


[misspelling] ~3315-~3315: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a ...

(EN_A_VS_AN)


[misspelling] ~3316-~3316: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id=...

(EN_A_VS_AN)


[misspelling] ~3337-~3337: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...us <a id...

(EN_A_VS_AN)


[misspelling] ~3338-~3338: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a> <a id="t...

(EN_A_VS_AN)


[misspelling] ~3365-~3365: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...on <a id...

(EN_A_VS_AN)


[misspelling] ~3366-~3366: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a> <a id="t...

(EN_A_VS_AN)


[misspelling] ~3394-~3394: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <...

(EN_A_VS_AN)


[misspelling] ~3395-~3395: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schema_ComplianceV2Response"> <a i...

(EN_A_VS_AN)


[misspelling] ~3418-~3418: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...OrderSide <a id="tocSo...

(EN_A_VS_AN)


[misspelling] ~3419-~3419: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ide"> <a id="tocsorde...

(EN_A_VS_AN)


[misspelling] ~3443-~3443: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...Liquidity <a id="tocSl...

(EN_A_VS_AN)


[misspelling] ~3444-~3444: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ity"> <a id="tocsliqu...

(EN_A_VS_AN)


[misspelling] ~3468-~3468: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...# FillType <a id="tocSfi...

(EN_A_VS_AN)


[misspelling] ~3469-~3469: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...type"> <a id="tocsfillt...

(EN_A_VS_AN)


[misspelling] ~3496-~3496: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...rketType <a id="tocS...

(EN_A_VS_AN)


[misspelling] ~3497-~3497: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...pe"> <a id="tocsmar...

(EN_A_VS_AN)


[misspelling] ~3521-~3521: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a ...

(EN_A_VS_AN)


[misspelling] ~3522-~3522: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id=...

(EN_A_VS_AN)


[misspelling] ~3567-~3567: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...sponse <a id="to...

(EN_A_VS_AN)


[misspelling] ~3568-~3568: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."> <a id="tocsf...

(EN_A_VS_AN)


[misspelling] ~3610-~3610: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...onse <a id="...

(EN_A_VS_AN)


[misspelling] ~3611-~3611: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id="toc...

(EN_A_VS_AN)


[misspelling] ~3632-~3632: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...chemahistoricalblocktradingreward"> <a id="schema_HistoricalBlockTradingReward...

(EN_A_VS_AN)


[misspelling] ~3633-~3633: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...hema_HistoricalBlockTradingReward"> <...

(EN_A_VS_AN)


[misspelling] ~3656-~3656: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...oricalblocktradingrewardsresponse"> <a id="schema_HistoricalBlockTradingReward...

(EN_A_VS_AN)


[misspelling] ~3657-~3657: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...oricalBlockTradingRewardsResponse"> <a id="tocShistoricalblocktradingrewardsre...

(EN_A_VS_AN)


[misspelling] ~3682-~3682: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...mahistoricalfundingresponseobject"> <a id="schema_HistoricalFundingResponseObj...

(EN_A_VS_AN)


[misspelling] ~3683-~3683: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a_HistoricalFundingResponseObject"> <a id="tocShistoricalfundingresponseobject...

(EN_A_VS_AN)


[misspelling] ~3710-~3710: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...="schemahistoricalfundingresponse"> <...

(EN_A_VS_AN)


[misspelling] ~3711-~3711: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."schema_HistoricalFundingResponse"> ...

(EN_A_VS_AN)


[misspelling] ~3738-~3738: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schemapnlticksresponseobject"> ...

(EN_A_VS_AN)


[misspelling] ~3739-~3739: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schema_PnlTicksResponseObject"> <a...

(EN_A_VS_AN)


[misspelling] ~3772-~3772: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schemahistoricalpnlresponse"> ...

(EN_A_VS_AN)


[misspelling] ~3773-~3773: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schema_HistoricalPnlResponse"> <a ...

(EN_A_VS_AN)


[misspelling] ~3809-~3809: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ematradingrewardaggregationperiod"> <a id="schema_TradingRewardAggregationPeri...

(EN_A_VS_AN)


[misspelling] ~3810-~3810: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ma_TradingRewardAggregationPeriod"> <a id="tocStradingrewardaggregationperiod"...

(EN_A_VS_AN)


[misspelling] ~3835-~3835: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...istoricaltradingrewardaggregation"> <a id="schema_HistoricalTradingRewardAggre...

(EN_A_VS_AN)


[misspelling] ~3836-~3836: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...istoricalTradingRewardAggregation"> <a id="tocShistoricaltradingrewardaggregat...

(EN_A_VS_AN)


[misspelling] ~3865-~3865: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...tradingrewardaggregationsresponse"> <a id="schema_HistoricalTradingRewardAggre...

(EN_A_VS_AN)


[misspelling] ~3866-~3866: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...TradingRewardAggregationsResponse"> <a id="tocShistoricaltradingrewardaggregat...

(EN_A_VS_AN)


[misspelling] ~3894-~3894: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...schemaorderbookresponsepricelevel"> <a id="schema_OrderbookResponsePriceLevel"...

(EN_A_VS_AN)


[misspelling] ~3895-~3895: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...chema_OrderbookResponsePriceLevel"> </...

(EN_A_VS_AN)


[misspelling] ~3916-~3916: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schemaorderbookresponseobject"> </a...

(EN_A_VS_AN)


[misspelling] ~3917-~3917: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schema_OrderbookResponseObject"> <...

(EN_A_VS_AN)


[misspelling] ~3948-~3948: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...orce <a id="...

(EN_A_VS_AN)


[misspelling] ~3949-~3949: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id="toc...

(EN_A_VS_AN)


[misspelling] ~3974-~3974: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...rStatus <a id="toc...

(EN_A_VS_AN)


[misspelling] ~3975-~3975: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...s"> <a id="tocsor...

(EN_A_VS_AN)


[misspelling] ~4002-~4002: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schemabesteffortopenedstatus"> ...

(EN_A_VS_AN)


[misspelling] ~4003-~4003: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schema_BestEffortOpenedStatus"> <a...

(EN_A_VS_AN)


[misspelling] ~4026-~4026: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...atus <a id="...

(EN_A_VS_AN)


[misspelling] ~4027-~4027: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id="toc...

(EN_A_VS_AN)


[misspelling] ~4052-~4052: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...OrderType <a id="tocSo...

(EN_A_VS_AN)


[misspelling] ~4053-~4053: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ype"> <a id="tocsorde...

(EN_A_VS_AN)


[misspelling] ~4082-~4082: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a...

(EN_A_VS_AN)


[misspelling] ~4083-~4083: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id...

(EN_A_VS_AN)


[misspelling] ~4146-~4146: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a id="schemaperpetualmarketstatus"> ...

(EN_A_VS_AN)


[misspelling] ~4147-~4147: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schema_PerpetualMarketStatus"> <a ...

(EN_A_VS_AN)


[misspelling] ~4175-~4175: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a...

(EN_A_VS_AN)


[misspelling] ~4176-~4176: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id...

(EN_A_VS_AN)


[misspelling] ~4200-~4200: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...hemaperpetualmarketresponseobject"> <a id="schema_PerpetualMarketResponseObjec...

(EN_A_VS_AN)


[misspelling] ~4201-~4201: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ema_PerpetualMarketResponseObject"> ...

(EN_A_VS_AN)


[misspelling] ~4260-~4260: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schemaperpetualmarketresponse"> </a...

(EN_A_VS_AN)


[misspelling] ~4261-~4261: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schema_PerpetualMarketResponse"> <...

(EN_A_VS_AN)


[misspelling] ~4328-~4328: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...="schemaperpetualpositionresponse"> <...

(EN_A_VS_AN)


[misspelling] ~4329-~4329: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."schema_PerpetualPositionResponse"> ...

(EN_A_VS_AN)


[misspelling] ~4367-~4367: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schemasparklineresponseobject"> </a...

(EN_A_VS_AN)


[misspelling] ~4368-~4368: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...d="schema_SparklineResponseObject"> <...

(EN_A_VS_AN)


[misspelling] ~4392-~4392: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a...

(EN_A_VS_AN)


[misspelling] ~4393-~4393: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id...

(EN_A_VS_AN)


[misspelling] ~4417-~4417: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...sponse <a id="to...

(EN_A_VS_AN)


[misspelling] ~4418-~4418: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."> <a id="tocst...

(EN_A_VS_AN)


[misspelling] ~4439-~4439: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...TradeType <a id="tocSt...

(EN_A_VS_AN)


[misspelling] ~4440-~4440: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ype"> <a id="tocstrad...

(EN_A_VS_AN)


[misspelling] ~4465-~4465: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a...

(EN_A_VS_AN)


[misspelling] ~4466-~4466: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... <a id...

(EN_A_VS_AN)


[misspelling] ~4497-~4497: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ponse <a id="t...

(EN_A_VS_AN)


[misspelling] ~4498-~4498: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...> <a id="tocs...

(EN_A_VS_AN)


[misspelling] ~4533-~4533: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...erType <a id="to...

(EN_A_VS_AN)


[misspelling] ~4534-~4534: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."> <a id="tocst...

(EN_A_VS_AN)


[misspelling] ~4560-~4560: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ... id="schematransferresponseobject"> ...

(EN_A_VS_AN)


[misspelling] ~4561-~4561: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...id="schema_TransferResponseObject"> <a...

(EN_A_VS_AN)


[misspelling] ~4606-~4606: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...se <a id...

(EN_A_VS_AN)


[misspelling] ~4607-~4607: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...a> <a id="t...

(EN_A_VS_AN)


[misspelling] ~4650-~4650: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...aparentsubaccounttransferresponse"> <a id="schema_ParentSubaccountTransferResp...

(EN_A_VS_AN)


[misspelling] ~4651-~4651: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..._ParentSubaccountTransferResponse"> <a id="tocSparentsubaccounttransferrespons...

(EN_A_VS_AN)

Markdownlint
indexer/services/comlink/public/api-documentation.md

4692-4692: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)


61-61: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


193-193: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


320-320: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


457-457: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


534-534: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


626-626: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


707-707: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


791-791: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


893-893: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


973-973: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1043-1043: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1118-1118: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1201-1201: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1290-1290: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1384-1384: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1459-1459: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1561-1561: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1747-1747: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1908-1908: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1997-1997: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2125-2125: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2225-2225: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2319-2319: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2384-2384: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2455-2455: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2541-2541: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


2635-2635: null
Blank line inside blockquote

(MD028, no-blanks-blockquote)


1626-1626: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1632-1632: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1638-1638: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1812-1812: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1818-1818: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1824-1824: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

Additional comments not posted (32)
indexer/services/comlink/public/api-documentation.md (32)

26-26: LGTM!

The code samples for Python and JavaScript are correctly formatted and demonstrate the usage of the API.

Also applies to: 38-38


69-69: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetAddress endpoint.


89-89: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


107-107: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


116-116: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


123-123: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


157-157: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


169-169: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


199-199: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetSubaccount endpoint.


219-219: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


237-237: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


246-246: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


253-253: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


284-284: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


296-296: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


326-326: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetParentSubaccount endpoint.


332-332: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


352-352: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


370-370: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


379-379: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


386-386: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example.


419-420: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


433-433: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


468-468: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetAssetPositions endpoint.


496-497: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


510-510: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


545-545: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetAssetPositionsForParentSubaccount endpoint.


573-573: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


587-587: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


642-642: LGTM!

The JSON response structure is correctly formatted and provides a comprehensive example for the GetCandles endpoint.


672-672: LGTM!

The Python code sample for making a GET request is correctly formatted and demonstrates the usage of the API.


684-684: LGTM!

The JavaScript code sample for making a GET request is correctly formatted and demonstrates the usage of the API.

Comment on lines 122 to 127
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Omit the unnecessary else clause.

This else clause can be omitted because the previous branch breaks early.

- } else {
-   return {
-     status: complianceStatus[0].status,
-     reason: complianceStatus[0].reason,
-   };
- }
+ return {
+   status: complianceStatus[0].status,
+   reason: complianceStatus[0].reason,
+ };
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
}
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
Tools
Biome

[error] 122-127: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Comment on lines 117 to 128
} else {
return {
status: ComplianceStatus.COMPLIANT,
};
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Omit the unnecessary else clause.

This else clause can be omitted because the previous branch breaks early.

- } else {
-   return {
-     status: ComplianceStatus.COMPLIANT,
-   };
- }
+ return {
+   status: ComplianceStatus.COMPLIANT,
+ };
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else {
return {
status: ComplianceStatus.COMPLIANT,
};
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
}
}
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
}
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
};
Tools
Biome

[error] 117-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-127: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

* For **Testnet**, use <a href="https://dydx-testnet.imperator.co/v4">https://dydx-testnet.imperator.co/v4</a>

Note: Messages on Indexer WebSocket feeds are typically more recent than data fetched via Indexer's REST API, because the latter is backed by read replicas of the databases that feed the former. Ordinarily this difference is minimal (less than a second), but it might become prolonged under load. Please see [Indexer Architecture](https://dydx.exchange/blog/v4-deep-dive-indexer) for more information.
* <a href=""></a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the empty anchor tag.

The anchor tag should have a valid URL or be removed if not needed.

- * <a href=""></a>
+ * <a href="https://example.com"></a> <!-- Replace with a valid URL or remove the line -->
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* <a href=""></a>
* <a href="https://example.com"></a> <!-- Replace with a valid URL or remove the line -->

Copy link
Contributor

@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.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts (3)

Line range hint 64-64: Remove invalid decorator usage.

Decorators are only valid on class declarations, class expressions, and class methods. The decorator on the screen method parameter is invalid.

- @Path() address: string,
+ address: string,

Line range hint 78-82: Omit the unnecessary else clause.

The else clause can be omitted because the previous branch returns early.

- } else {
-   return {
-     status: ComplianceStatus.COMPLIANT,
-   };
- }
+ return {
+   status: ComplianceStatus.COMPLIANT,
+ };

Line range hint 83-130: Omit the unnecessary else clause.

The else clause can be omitted because the previous branch returns early.

- } else {
-   const complianceStatus: ComplianceStatusFromDatabase[] = await
-   ComplianceStatusTable.findAll(
-     { address: [address] },
-     [],
-   );
-   if (restricted) {
-     let complianceStatusFromDatabase: ComplianceStatusFromDatabase | undefined;
-     const updatedAt: string = DateTime.utc().toISO();
-     if (complianceStatus.length === 0) {
-       complianceStatusFromDatabase = await ComplianceStatusTable.upsert({
-         address,
-         status: ComplianceStatus.BLOCKED,
-         reason: ComplianceReason.COMPLIANCE_PROVIDER,
-         updatedAt,
-       });
-     } else if (
-       complianceStatus[0].status !== ComplianceStatus.CLOSE_ONLY &&
-       complianceStatus[0].status !== ComplianceStatus.BLOCKED
-     ) {
-       complianceStatusFromDatabase = await ComplianceStatusTable.update({
-         address,
-         status: ComplianceStatus.CLOSE_ONLY,
-         reason: ComplianceReason.COMPLIANCE_PROVIDER,
-         updatedAt,
-       });
-     } else {
-       complianceStatusFromDatabase = complianceStatus[0];
-     }
-     return {
-       status: complianceStatusFromDatabase!.status,
-       reason: complianceStatusFromDatabase!.reason,
-       updatedAt: complianceStatusFromDatabase!.updatedAt,
-     };
-   } else {
-     if (complianceStatus.length === 0) {
-       return {
-         status: ComplianceStatus.COMPLIANT,
-       };
-     } else {
-       return {
-         status: complianceStatus[0].status,
-         reason: complianceStatus[0].reason,
-         updatedAt: complianceStatus[0].updatedAt,
-       };
-     }
-   }
- }
+ const complianceStatus: ComplianceStatusFromDatabase[] = await
+ ComplianceStatusTable.findAll(
+   { address: [address] },
+   [],
+ );
+ if (restricted) {
+   let complianceStatusFromDatabase: ComplianceStatusFromDatabase | undefined;
+   const updatedAt: string = DateTime.utc().toISO();
+   if (complianceStatus.length === 0) {
+     complianceStatusFromDatabase = await ComplianceStatusTable.upsert({
+       address,
+       status: ComplianceStatus.BLOCKED,
+       reason: ComplianceReason.COMPLIANCE_PROVIDER,
+       updatedAt,
+     });
+   } else if (
+     complianceStatus[0].status !== ComplianceStatus.CLOSE_ONLY &&
+     complianceStatus[0].status !== ComplianceStatus.BLOCKED
+   ) {
+     complianceStatusFromDatabase = await ComplianceStatusTable.update({
+       address,
+       status: ComplianceStatus.CLOSE_ONLY,
+       reason: ComplianceReason.COMPLIANCE_PROVIDER,
+       updatedAt,
+     });
+   } else {
+     complianceStatusFromDatabase = complianceStatus[0];
+   }
+   return {
+     status: complianceStatusFromDatabase!.status,
+     reason: complianceStatusFromDatabase!.reason,
+     updatedAt: complianceStatusFromDatabase!.updatedAt,
+   };
+ } 
+ if (complianceStatus.length === 0) {
+   return {
+     status: ComplianceStatus.COMPLIANT,
+   };
+ } 
+ return {
+   status: complianceStatus[0].status,
+   reason: complianceStatus[0].reason,
+   updatedAt: complianceStatus[0].updatedAt,
+ };
Tools
Biome

[error] 117-129: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d04b87 and bf795e6.

Files selected for processing (1)
  • indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts (2 hunks)
Additional context used
Biome
indexer/services/comlink/src/controllers/api/v4/compliance-v2-controller.ts

[error] 64-64: Decorators are not valid here.

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

(parse)


[error] 78-82: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 83-130: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 117-129: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 397-403: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

Comment on lines 117 to 129
} else {
return {
status: ComplianceStatus.COMPLIANT,
};
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
updatedAt: complianceStatus[0].updatedAt,
};
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Omit the unnecessary else clause.

The else clause can be omitted because the previous branch returns early.

- } else {
-   return {
-     status: complianceStatus[0].status,
-     reason: complianceStatus[0].reason,
-     updatedAt: complianceStatus[0].updatedAt,
-   };
- }
+ return {
+   status: complianceStatus[0].status,
+   reason: complianceStatus[0].reason,
+   updatedAt: complianceStatus[0].updatedAt,
+ };
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else {
return {
status: ComplianceStatus.COMPLIANT,
};
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
} else {
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
updatedAt: complianceStatus[0].updatedAt,
};
}
}
if (complianceStatus.length === 0) {
return {
status: ComplianceStatus.COMPLIANT,
};
}
return {
status: complianceStatus[0].status,
reason: complianceStatus[0].reason,
updatedAt: complianceStatus[0].updatedAt,
};
Tools
Biome

[error] 117-129: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)


[error] 122-128: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

@dydxwill dydxwill changed the title align screen & geoblock endpoints Align screen & geoblock compliance endpoints Jul 2, 2024
@dydxwill dydxwill merged commit 5a3502a into main Jul 2, 2024
10 of 11 checks passed
@dydxwill dydxwill deleted the wl/compliance_update branch July 2, 2024 17:07
@dydxwill
Copy link
Contributor Author

dydxwill commented Jul 3, 2024

@Mergifyio backport release/indexer/v5.x

Copy link
Contributor

mergify bot commented Jul 3, 2024

backport release/indexer/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 3, 2024
dydxwill added a commit that referenced this pull request Jul 3, 2024
Co-authored-by: dydxwill <119354122+dydxwill@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants