Skip to content

Divide DepositOrWithdrawModal into Deposit and Withdraw#1870

Merged
hardingjam merged 8 commits intomainfrom
Split-deposit-and-remove-modals
May 27, 2025
Merged

Divide DepositOrWithdrawModal into Deposit and Withdraw#1870
hardingjam merged 8 commits intomainfrom
Split-deposit-and-remove-modals

Conversation

@hardingjam
Copy link
Copy Markdown
Contributor

@hardingjam hardingjam commented May 20, 2025

Motivation

Separating the concerns of deposit/withdraw modals will make it easier to incrementally move the transactions into the new TransactionManager (see #1797, #1796)

Solution

Divide DepositOrWithdrawModal into seperate components.

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

  • New Features
    • Introduced a dedicated Withdraw Modal for handling withdrawals with improved user experience and validation.
  • Refactor
    • Separated deposit and withdraw functionality into distinct modals and handlers for clearer workflows.
    • Simplified Deposit Modal to focus exclusively on deposit actions.
    • Updated modal service and related logic to use separate handlers for deposits and withdrawals.
    • Renamed types and callback properties to unify and clarify modal argument structures.
    • Updated vault action handling to include query client and key for improved cache management.
  • Tests
    • Added comprehensive tests for the new Withdraw Modal.
    • Updated Deposit Modal tests to focus solely on deposit scenarios.
    • Added tests for vault action handling verifying deposit and withdrawal flows and cache invalidation.

@hardingjam hardingjam self-assigned this May 20, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2025

## Walkthrough

This change refactors the handling of deposit and withdraw actions by splitting the combined modal components, types, handlers, and tests into separate deposit and withdraw versions. Types and props are renamed and adjusted accordingly, and all related logic, UI, and tests are updated to use the new structure.

## Changes

| File(s)                                                                                           | Change Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| packages/ui-components/src/lib/index.ts<br>packages/ui-components/src/lib/types/modal.ts<br>packages/ui-components/src/lib/types/transaction.ts | Renamed types: `DepositOrWithdrawArgs``VaultActionArgs`, `DepositOrWithdrawModalProps``VaultActionModalProps`. Updated property names and removed the `action` property. Adjusted exports and prop types to match the new naming and structure.                                                                                                                                                                                                                                                                                                                               |
| packages/webapp/src/lib/components/DepositModal.svelte                                           | Refactored to handle only deposit actions. Updated prop type to `VaultActionArgs`, removed all withdrawal-related logic, and simplified UI and validation accordingly.                                                                                                                                                                                                                                                                                                                                                                                                                 |
| packages/webapp/src/lib/components/WithdrawModal.svelte                                          | Added a new component to handle withdraw actions, with its own state management, validation, and transaction flow, mirroring the structure of the deposit modal but focused on withdrawals.                                                                                                                                                                                                                                                                                                                                                                                            |
| packages/webapp/src/lib/services/modal.ts                                                        | Split the combined modal handler into `handleDepositModal` and `handleWithdrawModal`, each invoking their respective modal component. Updated prop types and imports to match the new structure.                                                                                                                                                                                                                                                                                                                                                                                       |
| packages/webapp/src/lib/services/handleVaultAction.ts                                            | Renamed parameter interface and updated function signature to include `queryClient` and `queryKey`, removed `vaultId`. Replaced single modal handler call with conditional calls to `handleDepositModal` or `handleWithdrawModal` based on action. Updated callback and argument properties accordingly.                                                                                                                                                                                                                                                                              |
| packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte<br>packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte | Updated to use the new separate modal handlers and types. Removed the `action` prop, updated callback property names, and improved safety in accessing configuration values. Logic now chooses the appropriate handler based on action type.                                                                                                                                                                                                                                                                                                                                             |
| packages/webapp/src/__tests__/DepositModal.test.ts                                               | Refactored tests to focus exclusively on deposit functionality. Removed all withdraw-related tests, props, and logic. Updated test IDs, button references, and mocks for deposit-only scenarios.                                                                                                                                                                                                                                                                                                                                                                                        |
| packages/webapp/src/__tests__/WithdrawModal.test.ts                                              | Added a new test suite for the withdraw modal component, covering rendering, user interactions, error handling, validation, and transaction flow for withdrawal actions.                                                                                                                                                                                                                                                                                                                                                                                                                |
| packages/ui-components/src/__tests__/awaitTransactionIndexing.test.ts                            | Modified mocked error response format in fetch error test and removed assertion on number of fetch calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Page
    participant ModalService
    participant DepositModal
    participant WithdrawModal
    participant TransactionStore

    User->>Page: Clicks "Deposit" or "Withdraw"
    Page->>ModalService: handleDepositModal(args) or handleWithdrawModal(args)
    ModalService->>DepositModal: Open (for deposit)
    ModalService->>WithdrawModal: Open (for withdraw)
    User->>DepositModal: Enter amount, submit
    DepositModal->>TransactionStore: Initiate deposit transaction
    TransactionStore-->>DepositModal: Transaction result
    User->>WithdrawModal: Enter amount, submit
    WithdrawModal->>TransactionStore: Initiate withdraw transaction
    TransactionStore-->>WithdrawModal: Transaction result

Possibly related PRs

Suggested labels

refactor, test

Suggested reviewers

  • hardyjosh
  • findolor

<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 ESLint</summary>
> 
> > If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
> 
> npm warn config production Use `--omit=dev` instead.
> npm error Exit handler never called!
> npm error This is an error with npm itself. Please report this error at:
> npm error   <https://github.com/npm/cli/issues>
> npm error A complete log of this run can be found in: /.npm/_logs/2025-05-27T07_48_57_592Z-debug-0.log
> 
> 
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: ASSERTIVE**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between b714523d279fd3168727de3596739389e400d0e5 and c2577504b23282e76f6f0c8b5cb50b5f591dc7be.

</details>

<details>
<summary>📒 Files selected for processing (5)</summary>

* `packages/ui-components/src/__tests__/awaitTransactionIndexing.test.ts` (1 hunks)
* `packages/webapp/src/__tests__/handleVaultAction.test.ts` (1 hunks)
* `packages/webapp/src/lib/services/handleVaultAction.ts` (1 hunks)
* `packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte` (2 hunks)
* `packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (2)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: hardingjam
PR: #1870
File: packages/webapp/src/lib/components/WithdrawModal.svelte:31-31
Timestamp: 2025-05-20T12:03:18.032Z
Learning: The VaultActionArgs type no longer contains an action property after refactoring the deposit/withdraw modals into separate components.


</details>
<details>
<summary>packages/webapp/src/lib/services/handleVaultAction.ts (1)</summary>

Learnt from: hardingjam
PR: #1870
File: packages/webapp/src/lib/components/WithdrawModal.svelte:31-31
Timestamp: 2025-05-20T12:03:18.032Z
Learning: The VaultActionArgs type no longer contains an action property after refactoring the deposit/withdraw modals into separate components.


</details>

</details><details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>packages/webapp/src/__tests__/handleVaultAction.test.ts (2)</summary><blockquote>

<details>
<summary>packages/webapp/src/lib/services/handleVaultAction.ts (1)</summary>

* `handleVaultAction` (18-42)

</details>
<details>
<summary>packages/webapp/src/lib/services/modal.ts (2)</summary>

* `handleDepositModal` (17-19)
* `handleWithdrawModal` (21-23)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (10)</summary>

* GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
* GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
* GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
* GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
* GitHub Check: test
* GitHub Check: test
* GitHub Check: Deploy-Preview
* GitHub Check: test
* GitHub Check: build-tauri (ubuntu-22.04, true)
* GitHub Check: git-clean

</details>

<details>
<summary>🔇 Additional comments (16)</summary><blockquote>

<details>
<summary>packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte (3)</summary>

`9-9`: **LGTM! Import path correctly updated.**

The import path has been properly updated to reflect the refactored service structure.

---

`19-29`: **LGTM! Parameters correctly updated for new API.**

The `handleVaultAction` calls have been properly updated with the new `queryClient` and `queryKey` parameters, which replace the previous `vaultId` parameter and enable proper query invalidation after vault actions complete.

---

`32-42`: **LGTM! Parameters correctly updated for new API.**

The withdraw action call has been properly updated with the same new parameters as the deposit action, maintaining consistency.

</details>
<details>
<summary>packages/ui-components/src/__tests__/awaitTransactionIndexing.test.ts (1)</summary>

`105-105`: **LGTM! Simplified error structure improves test clarity.**

The simplified error response structure makes the test more focused and easier to understand while maintaining the same test coverage for error handling scenarios.

</details>
<details>
<summary>packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte (4)</summary>

`14-14`: **LGTM! Import path correctly updated.**

The import path has been properly updated to match the refactored service structure.

---

`20-22`: **LGTM! Added defensive programming with optional chaining.**

The addition of optional chaining and default fallbacks prevents potential runtime errors when settings are undefined, improving robustness.

---

`40-50`: **LGTM! Parameters correctly updated for new API.**

The deposit action call has been properly updated with the new `queryClient` and `queryKey` parameters, maintaining consistency with the refactored service API.

---

`53-63`: **LGTM! Parameters correctly updated for new API.**

The withdraw action call has been properly updated with the same new parameters, maintaining consistency across both actions.

</details>
<details>
<summary>packages/webapp/src/__tests__/handleVaultAction.test.ts (5)</summary>

`1-33`: **LGTM! Excellent test setup and imports.**

The test file has comprehensive imports and proper mocking setup. The mock configuration correctly isolates the units under test while preserving necessary functionality from ui-components.

---

`35-60`: **LGTM! Thorough test coverage for deposit action.**

The test correctly verifies that:
- `handleDepositModal` is called with the correct parameters
- `handleWithdrawModal` is not called
- All parameters are passed through properly

This ensures the action routing works correctly.

---

`62-87`: **LGTM! Thorough test coverage for withdraw action.**

The test correctly verifies the inverse scenario, ensuring that:
- `handleWithdrawModal` is called with the correct parameters  
- `handleDepositModal` is not called
- Parameters are passed through properly

This complements the deposit test perfectly.

---

`89-107`: **LGTM! Excellent test for query invalidation.**

The test correctly verifies that the `onSuccess` callback triggers query invalidation with the proper parameters. The approach of extracting the callback from the mock call and invoking it directly is a good testing pattern.

---

`109-127`: **LGTM! Complete test coverage for query invalidation.**

This test ensures that query invalidation works correctly for withdraw actions as well, maintaining symmetry with the deposit test and providing complete coverage of the functionality.

</details>
<details>
<summary>packages/webapp/src/lib/services/handleVaultAction.ts (3)</summary>

`2-5`: **LGTM! Import statements align with the refactoring.**

The import changes correctly support the split modal architecture:
- Added `invalidateTanstackQueries` for improved query cache management
- Added `Hex` type for proper account parameter typing  
- Replaced combined modal handler with separate deposit/withdraw handlers

---

`7-16`: **Well-structured interface for the refactored functionality.**

The renamed `HandleVaultActionParams` interface effectively supports the modal separation:
- Addition of `queryClient` and `queryKey` enables flexible cache invalidation
- Proper typing with `Hex` for account and union type for action
- Clear parameter structure that aligns with the new modal handlers

---

`18-42`: **Excellent implementation of the modal separation logic.**

The function correctly implements the refactoring objectives:
- Type-safe conditional selection between deposit and withdraw modal handlers
- Proper parameter forwarding to the selected handler
- Improved callback naming (`onSuccess` vs `onDepositOrWithdraw`)
- Flexible query invalidation using `queryKey` parameter
- Clean separation that supports the incremental TransactionManager migration

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgARSXglSHiSbnxEdQB5CgB1dVhaKgB3AFlFNF94DAJU9Mz1dAx6Atwi0tjm+gcBZnUaejlIbERKSFhnWhqiITRmdGRbSAxHAXGARgAOAHYABnDtZmQ6se5nahII2CumZjV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QCLnRXwb9RxdYKUX7ZdZ4CEhLfCAiCU8AT8Crq/DuDvxuIvwAxlgn/iKA8EwCQhGAggQ3w346ga3MkEQDW5TBQKdxLQGtxqJTaxCSBJAFlgMA4wGwDYCmD2A7A6IAAVi2C30UwXS+SCQFvpbAUwDAWWHGC6UkAAAzAwD2Apg2QTS9YLQC2BdK4wuUK+A0oEA7ANgssLpbfSmW0Bb68YNkLQCmVtLdgRypQFMtWUpgdgUyuMFMq2BxgSAssPYHsFoB7ASAXS/JQYAaUMBb6XSnYDsC6V7BZYAgfZcMtvokAdg8y+ZXsAYBbABAAypFXsCRVshVlGwWgAwB2CKR6lhSlJcUtKXlLlIlSugNbjvj6AgAA -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=rainlanguage/rain.orderbook&utm_content=1870):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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 explain this code block.`
  -	`@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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@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.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

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 using 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 generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this 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.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@hardingjam hardingjam requested review from findolor and hardyjosh May 20, 2025 10:14
@hardingjam hardingjam added this to the Test coverage, tech debt milestone May 20, 2025
@hardingjam hardingjam changed the title split modals Divide DepositOrWithdrawModal into Deposit and Withdraw May 20, 2025
Copy link
Copy Markdown
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: 11

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd19e2d and 4c91160.

📒 Files selected for processing (10)
  • packages/ui-components/src/lib/index.ts (1 hunks)
  • packages/ui-components/src/lib/types/modal.ts (1 hunks)
  • packages/ui-components/src/lib/types/transaction.ts (1 hunks)
  • packages/webapp/src/__tests__/DepositModal.test.ts (18 hunks)
  • packages/webapp/src/__tests__/WithdrawModal.test.ts (1 hunks)
  • packages/webapp/src/lib/components/DepositModal.svelte (6 hunks)
  • packages/webapp/src/lib/components/WithdrawModal.svelte (1 hunks)
  • packages/webapp/src/lib/services/modal.ts (2 hunks)
  • packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte (3 hunks)
  • packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
packages/ui-components/src/lib/types/modal.ts (1)
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
packages/webapp/src/lib/components/DepositModal.svelte (1)
Learnt from: findolor
PR: rainlanguage/rain.orderbook#1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte (1)
Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1504
File: tauri-app/src/routes/orders/[network]-[orderHash]/+page.svelte:33-37
Timestamp: 2025-04-08T16:35:15.127Z
Learning: In the Rain OrderBook project, the onDeposit and onWithdraw functions in page components are kept simple (just calling modal handlers and revalidating queries) because error handling for deposit and withdraw actions (including user cancellations and failed transactions) is handled within the modal components themselves.
packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte (1)
Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1504
File: tauri-app/src/routes/orders/[network]-[orderHash]/+page.svelte:33-37
Timestamp: 2025-04-08T16:35:15.127Z
Learning: In the Rain OrderBook project, the onDeposit and onWithdraw functions in page components are kept simple (just calling modal handlers and revalidating queries) because error handling for deposit and withdraw actions (including user cancellations and failed transactions) is handled within the modal components themselves.
🧬 Code Graph Analysis (2)
packages/webapp/src/lib/services/modal.ts (1)
packages/ui-components/src/lib/types/modal.ts (1)
  • VaultActionModalProps (4-7)
packages/ui-components/src/lib/types/modal.ts (2)
packages/ui-components/src/lib/index.ts (2)
  • VaultActionModalProps (80-80)
  • VaultActionArgs (78-78)
packages/ui-components/src/lib/types/transaction.ts (1)
  • VaultActionArgs (14-21)
🔇 Additional comments (23)
packages/ui-components/src/lib/types/transaction.ts (1)

14-16: Type signature change improves modularity

The change from DepositOrWithdrawArgs to VaultActionArgs and updating the callback from onDepositOrWithdraw to the more generic onSuccess is well-structured. Removing the action property moves the action responsibility to the component level rather than being determined by a property.

packages/ui-components/src/lib/types/modal.ts (1)

2-7: Modal props update aligns with component splitting strategy

The renamed VaultActionModalProps type and updated import properly reflect the changes to separate deposit and withdraw functionality. This creates a more focused type that works well with the new modal component architecture.

packages/ui-components/src/lib/index.ts (1)

78-80: Export updates ensure API consistency

The exports have been properly updated to use the new type names, maintaining a consistent public API for consumers of the library.

packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte (2)

5-5: Import reflects modal component separation

The import change from a combined handler to separate handleDepositModal and handleWithdrawModal functions aligns with the PR's goal of separating these concerns.


19-34: Modal handler selection logic is clean and maintainable

The refactored handleVaultAction function elegantly selects the appropriate modal handler based on action type. The callback rename from onDepositOrWithdraw to onSuccess makes the code more intuitive and aligns with the PR objectives.

packages/webapp/src/lib/services/modal.ts (3)

3-4: Clean implementation of split modal components.

The previously combined DepositOrWithdrawModal has been properly split into dedicated DepositModal and WithdrawModal components, aligning with the PR objective to facilitate incremental migration to the new TransactionManager.


7-7: Type rename is consistent.

Good replacement of DepositOrWithdrawModalProps with VaultActionModalProps, maintaining type safety while reflecting the component restructuring.


17-23: Well-structured modal handlers.

The split into separate handlers follows the established pattern in the file. Each handler instantiates its respective component with the appropriate props structure, maintaining consistency with other modal handlers.

packages/webapp/src/lib/components/DepositModal.svelte (6)

6-6: Proper type import update.

Correctly updated import to use the new VaultActionArgs type to reflect the separation of concerns.


35-37: Clean props destructuring.

The component now correctly uses VaultActionArgs and removes action-related conditionals, focusing solely on deposit functionality.


72-107: Simplified transaction handling.

The handleContinue function is now cleaner and more focused by removing withdrawal-specific logic. The VaultCalldataResult handling correctly extracts and passes the inner value to handleTransaction, consistent with the project's established pattern.


122-124: Streamlined validation.

Validation logic is simplified by directly using userBalance without conditional checks for action type.


130-130: Updated UI text for clarity.

Modal title now clearly indicates this is exclusively for deposit actions.


175-182: Clearer button labeling.

Button text and test ID are updated to be deposit-specific, improving clarity and test stability.

packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte (3)

10-14: Clean import structure.

Imports are properly updated to use the new separate modal handlers, using a more organized import syntax.


23-25: Improved error resilience.

Good defensive programming with fallback values for subgraphUrl, rpcUrl, and chainId to prevent undefined values.


43-58: Well-structured modal selection.

The handleVaultAction function now elegantly selects the appropriate modal handler based on the action type. The callback property rename from onDepositOrWithdraw to onSuccess is clearer and more consistent with typical event handler naming conventions.

packages/webapp/src/__tests__/DepositModal.test.ts (6)

3-3: Updated component import.

Test file correctly imports the new DepositModal component instead of the previous combined modal.


7-8: Focused imports for deposit functionality.

Import list has been properly updated to include only deposit-related functions.


19-21: Simplified mocks.

Mock implementations are correctly updated to focus only on deposit-related functions.


39-39: Updated test suite name.

Test suite name now accurately reflects that it's testing the DepositModal component.


71-74: Updated test rendering and assertions.

Tests are properly updated to render the DepositModal component and check for deposit-specific elements using the correct test IDs.


228-246: Focused test cases.

Test cases are properly updated to focus only on deposit-specific scenarios, maintaining good test coverage for the specific component responsibilities.

Comment thread packages/webapp/src/routes/vaults/[network]-[id]/+page.svelte Outdated
Comment thread packages/webapp/src/__tests__/WithdrawModal.test.ts
Comment thread packages/webapp/src/__tests__/WithdrawModal.test.ts
Comment thread packages/webapp/src/__tests__/WithdrawModal.test.ts
Comment on lines +291 to +303
it('shows the cancel button that closes the modal', async () => {
render(WithdrawModal, defaultProps);

await waitFor(() => {
expect(screen.getByText('Cancel')).toBeInTheDocument();
});

const cancelButton = screen.getByText('Cancel');
await fireEvent.click(cancelButton);
await waitFor(() => {
expect(transactionStore.reset).not.toHaveBeenCalled();
});
});
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 20, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve cancel button test to verify modal closing.

The test verifies that the cancel button exists and that transactionStore.reset is not called, but it doesn't verify that the modal is actually closed. Consider updating this test to verify that the open prop is set to false when the cancel button is clicked.

 it('shows the cancel button that closes the modal', async () => {
+    const mockProps = {
+        ...defaultProps,
+        open: true
+    };
-    render(WithdrawModal, defaultProps);
+    const { component } = render(WithdrawModal, mockProps);

     await waitFor(() => {
         expect(screen.getByText('Cancel')).toBeInTheDocument();
     });

     const cancelButton = screen.getByText('Cancel');
     await fireEvent.click(cancelButton);
     await waitFor(() => {
         expect(transactionStore.reset).not.toHaveBeenCalled();
+        expect(component.open).toBe(false);
     });
 });

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/webapp/src/__tests__/WithdrawModal.test.ts around lines 291 to 303,
the test for the cancel button currently checks its presence and that
transactionStore.reset is not called, but does not verify that the modal closes.
Update the test to simulate clicking the cancel button and then assert that the
modal's open state is set to false, confirming the modal closes as expected.

Copy link
Copy Markdown
Contributor Author

@hardingjam hardingjam May 20, 2025

Choose a reason for hiding this comment

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

the modal closing is native flowbite behaviour

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hardingjam Thanks for clarifying that the modal closing is handled by Flowbite's native behavior. That makes sense - since Flowbite manages the modal state internally, checking the component's open prop value wouldn't be an effective way to verify the closing functionality. The current test approach is appropriate given this architecture.

🐰


✏️ Learnings added
Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1870
File: packages/webapp/src/__tests__/WithdrawModal.test.ts:291-303
Timestamp: 2025-05-20T12:05:48.544Z
Learning: The modal closing behavior in the WithdrawModal component is handled by Flowbite's native implementation rather than through component props, making it unnecessary to test the open state changes directly.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment thread packages/webapp/src/lib/components/WithdrawModal.svelte
Comment on lines +79 to +94
async function handleContinue() {
isCheckingCalldata = true;
try {
const withdrawCalldataResult = await getVaultWithdrawCalldata(vault, amount.toString());
if (withdrawCalldataResult.error) {
errorMessage = withdrawCalldataResult.error.msg;
} else {
handleTransaction(withdrawCalldataResult.value);
}
currentStep = 2;
} catch {
errorMessage = 'Failed to get calldata.';
} finally {
isCheckingCalldata = false;
}
}
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 20, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix error handling in handleContinue function.

There's an issue with the control flow in the handleContinue function. Even when an error occurs, the code still sets currentStep = 2, which moves the user to the next step. This could lead to a confusing user experience.

 async function handleContinue() {
     isCheckingCalldata = true;
     try {
         const withdrawCalldataResult = await getVaultWithdrawCalldata(vault, amount.toString());
         if (withdrawCalldataResult.error) {
             errorMessage = withdrawCalldataResult.error.msg;
+            return; // Don't proceed to step 2 if there's an error
         } else {
             handleTransaction(withdrawCalldataResult.value);
+            currentStep = 2; // Only move to step 2 on success
         }
-        currentStep = 2;
     } catch {
         errorMessage = 'Failed to get calldata.';
     } finally {
         isCheckingCalldata = false;
     }
 }
📝 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
async function handleContinue() {
isCheckingCalldata = true;
try {
const withdrawCalldataResult = await getVaultWithdrawCalldata(vault, amount.toString());
if (withdrawCalldataResult.error) {
errorMessage = withdrawCalldataResult.error.msg;
} else {
handleTransaction(withdrawCalldataResult.value);
}
currentStep = 2;
} catch {
errorMessage = 'Failed to get calldata.';
} finally {
isCheckingCalldata = false;
}
}
async function handleContinue() {
isCheckingCalldata = true;
try {
const withdrawCalldataResult = await getVaultWithdrawCalldata(vault, amount.toString());
if (withdrawCalldataResult.error) {
errorMessage = withdrawCalldataResult.error.msg;
return; // Don't proceed to step 2 if there's an error
} else {
handleTransaction(withdrawCalldataResult.value);
currentStep = 2; // Only move to step 2 on success
}
} catch {
errorMessage = 'Failed to get calldata.';
} finally {
isCheckingCalldata = false;
}
}
🤖 Prompt for AI Agents
In packages/webapp/src/lib/components/WithdrawModal.svelte around lines 79 to
94, the handleContinue function sets currentStep = 2 even when an error occurs,
causing incorrect progression in the UI. Modify the code so that currentStep = 2
is only set when there is no error in withdrawCalldataResult and no exception is
thrown. Move the currentStep assignment inside the else block where
handleTransaction is called, and avoid setting it in the catch block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good spot, thank you

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hardingjam You're welcome! I'm glad I could help identify that issue. Feel free to let me know if you need any more assistance with this PR.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Comment thread packages/webapp/src/lib/components/WithdrawModal.svelte
export let open: boolean;
export let args: VaultActionArgs;

const { vault, chainId, subgraphUrl, account } = args;
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 20, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing callback invocation for transaction completion.

The component destructures args to access various properties, but there's no mention of the callback function (onDepositOrWithdraw or onSuccess) that should be called when a transaction is complete. If the component is supposed to notify its parent when a transaction is complete, this callback should be destructured and called at the appropriate time.

-const { vault, chainId, subgraphUrl, account } = args;
+const { vault, chainId, subgraphUrl, account, onSuccess } = args;

// Then call it after successful transaction
 async function handleTransaction(transactionCalldata: VaultCalldataResult) {
     transactionStore.handleDepositOrWithdrawTransaction({
         config: $wagmiConfig,
         transactionCalldata,
         action: 'withdraw',
         chainId,
         vault,
         subgraphUrl
     });
+    // Call the callback when transaction is complete
+    if (onSuccess) {
+        onSuccess();
+    }
 }
📝 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
const { vault, chainId, subgraphUrl, account } = args;
const { vault, chainId, subgraphUrl, account, onSuccess } = args;
async function handleTransaction(transactionCalldata: VaultCalldataResult) {
transactionStore.handleDepositOrWithdrawTransaction({
config: $wagmiConfig,
transactionCalldata,
action: 'withdraw',
chainId,
vault,
subgraphUrl
});
// Call the callback when transaction is complete
if (onSuccess) {
onSuccess();
}
}
🤖 Prompt for AI Agents
In packages/webapp/src/lib/components/WithdrawModal.svelte at line 33, the
destructuring of args misses extracting the callback function (such as
onDepositOrWithdraw or onSuccess) that should be called upon transaction
completion. Update the destructuring to include the appropriate callback
function from args, then ensure this callback is invoked at the correct point in
the transaction flow to notify the parent component when the transaction
finishes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the TransactionModal handles success and the listener handles adding toasts
This behaviour is refactored as we move the transactions to the TransactionManager

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hardingjam Thanks for clarifying the architecture. I understand now that success handling is delegated to the TransactionModal component and listeners rather than directly calling the callback. This makes sense as part of your incremental migration to the new TransactionManager mentioned in the PR description.


✏️ Learnings added
Learnt from: hardingjam
PR: rainlanguage/rain.orderbook#1870
File: packages/webapp/src/lib/components/WithdrawModal.svelte:33-33
Timestamp: 2025-05-20T12:01:28.354Z
Learning: In the rain.orderbook project, transaction success handling in modal components is managed by the TransactionModal component and listeners that handle adding toasts, rather than directly invoking callbacks. This is part of the architecture being refactored as transactions are moved to the TransactionManager.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment thread packages/webapp/src/lib/components/WithdrawModal.svelte
Copy link
Copy Markdown
Collaborator

@findolor findolor left a comment

Choose a reason for hiding this comment

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

do you think having a generic modal would work for both deposit and withdraw? i see that the ui elements are mostly the same aside from simple text changes. i think we can reduce the amount of template code by creating a shared component. curious about what you think

@hardingjam
Copy link
Copy Markdown
Contributor Author

hardingjam commented May 21, 2025

do you think having a generic modal would work for both deposit and withdraw? i see that the ui elements are mostly the same aside from simple text changes. i think we can reduce the amount of template code by creating a shared component. curious about what you think

Issue #1794 will remove the need for separate modals, but I'm moving each transaction over one by one, so for now I need to keep the 'old' DepsoitModal until I migrate that transaction.

Made an issue to re-merge these: #1879

@hardingjam hardingjam linked an issue May 21, 2025 that may be closed by this pull request
@hardingjam hardingjam enabled auto-merge May 27, 2025 08:26
@hardingjam hardingjam merged commit a50c804 into main May 27, 2025
17 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 7, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seperate deposit and withdraw modals

3 participants