Skip to content

Conversation

@findolor
Copy link
Collaborator

@findolor findolor commented Dec 5, 2025

Chained PR

Motivation

Just like the add order functionality, we are now implementing the polling mechanism to remove order path.

Solution

  • Update getRemoveOrdersForTransaction wasm binding to poll from local db and subgraph
  • Update TransactionManager to use sdk based indexing logic
  • Add and update tests

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messaging for subgraph indexing timeout scenarios
    • Enhanced remove order indexing robustness with configurable retry logic and local database fallback support
  • Tests

    • Added comprehensive test coverage for transaction manager, including success/error handling and SDK-based indexing workflows
  • Chores

    • Updated .gitignore configuration

✏️ Tip: You can customize this high-level summary in your review settings.

@findolor findolor requested review from 0xgleb and hardyjosh December 5, 2025 08:34
@findolor findolor self-assigned this Dec 5, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a two-phase polling mechanism for fetching remove orders (querying local database first, then subgraph with retry logic), expose a WASM binding with configurable polling parameters, update error messaging, and integrate the new SDK-based indexing approach in the UI transaction manager with corresponding test coverage.

Changes

Cohort / File(s) Summary
Subgraph Polling Implementation
crates/common/src/raindex_client/remove_orders.rs
Added two-phase polling: local DB query (if available) followed by subgraph polling with configurable attempts and intervals. Introduced get_remove_orders_for_transaction_wasm_binding WASM entry point and made original method private. Added sleep_ms helper for platform-specific delays and DEFAULT_REMOVE_ORDER_POLL_* constants. Expanded tests to cover polling success, timeout, and local DB preference scenarios.
Error Messaging
crates/common/src/raindex_client/mod.rs
Updated RaindexError::SubgraphIndexingTimeout error attribute from multi-line to single-line format.
UI Transaction Integration
packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
Replaced subgraph indexing wrapper with SDK-based indexing function that calls raindexClient.getRemoveOrdersForTransaction. Success now determined by non-empty array result. Removed RaindexTransaction type import.
Transaction Manager Tests
packages/ui-components/src/__tests__/TransactionManager.test.ts
Added tests validating successful and failed transaction paths, SDK-based indexing workflow, query invalidation, toast/error handling, and SDK timeout handling.
Configuration
.gitignore
Added .cursor/ directory to ignore rules under AI Docs.

Sequence Diagram

sequenceDiagram
    participant UI as UI Layer
    participant TM as TransactionManager
    participant RC as RaindexClient
    participant LDB as Local DB
    participant SG as Subgraph
    
    UI->>TM: createRemoveOrderTransaction()
    TM->>RC: get_remove_orders_for_transaction_wasm_binding()
    RC->>LDB: Query local database
    alt Local DB Available & Supported
        LDB-->>RC: Return orders (if found)
        alt Orders Found
            RC-->>TM: Return orders
        else Orders Empty
            Note over RC: Proceed to subgraph polling
            RC->>SG: Poll for orders (attempt 1)
            loop Retry with interval
                alt Orders Found
                    SG-->>RC: Return orders
                    RC-->>TM: Return orders
                else Empty/Error
                    RC->>RC: Sleep interval_ms
                    RC->>SG: Poll for orders (attempt N)
                end
            end
            alt Max Attempts Exceeded
                RC-->>TM: SubgraphIndexingTimeout error
            end
        end
    else Local DB Unavailable
        Note over RC: Skip to subgraph polling
        RC->>SG: Poll for orders (attempt 1)
        loop Retry with interval
            alt Orders Found
                SG-->>RC: Return orders
                RC-->>TM: Return orders
            else Empty/Error
                RC->>RC: Sleep interval_ms
                RC->>SG: Poll for orders (attempt N)
            end
        end
        alt Max Attempts Exceeded
            RC-->>TM: SubgraphIndexingTimeout error
        end
    end
    TM-->>UI: Invoke onSuccess/onError callback
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

  • remove_orders.rs: Contains the bulk of complexity with two-phase polling logic, platform-specific sleep utilities, WASM binding parameter conversion, and comprehensive test coverage including edge cases (timeout, local DB preference, retry logic). This file warrants careful review of retry/polling semantics and error handling paths.
  • WASM binding signature conversion: Parameter type conversion from optional u32 (WASM) to Option<usize> and Option<u64> (internal) requires verification of boundary conditions and overflow handling.
  • Platform-specific code: The sleep_ms conditional compilation for WASM vs. non-WASM environments should be verified for correctness in both contexts.

Possibly related PRs

Suggested labels

enhancement, test

Suggested reviewers

  • hardyjosh
  • 0xgleb

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and does not clearly convey the main changes in the changeset, which involve implementing a two-phase polling mechanism for remove orders with SDK integration. Revise the title to be more specific and descriptive, such as 'Implement polling mechanism for remove order indexing with local DB and subgraph fallback' to clearly communicate the primary change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

@findolor
Copy link
Collaborator Author

findolor commented Dec 5, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@findolor findolor force-pushed the 2025-12-05-remove-order-polling branch from cb71258 to 16b357c Compare December 5, 2025 10:56
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.

3 participants