Skip to content

feat(rpc): trading-related RPCs/types#191

Merged
CharlVS merged 29 commits intodevfrom
cursor/only-types-and-rpc-from-0a9c
Aug 18, 2025
Merged

feat(rpc): trading-related RPCs/types#191
CharlVS merged 29 commits intodevfrom
cursor/only-types-and-rpc-from-0a9c

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Aug 15, 2025

This PR was created from branch cursor/only-types-and-rpc-from-0a9c.

Goal

  • Undo all changes relative to dev except those in:
    • packages/komodo_defi_types
    • packages/komodo_defi_rpc_methods

Implementation

  • Branched from origin/cursor/build-swap-manager-in-sdk-0a9c
  • Restored repository state to origin/dev
  • Restored and committed only the changes in the types and RPC packages

Notes

  • komodo_defi_types: tests pass
  • komodo_defi_rpc_methods: tests failing around legacy casing in PrivateKeyPolicy.fromLegacyJson and missing password in unban_pubkeys request payload. Can fix here or in a follow-up.

Diff is limited to the packages above.

Summary by CodeRabbit

  • New Features

    • Added Lightning operations: open/close channels, get channel details, claimable balances, payment history, generate/pay invoices.
    • Introduced orderbook actions: best orders with flexible request, my orders, cancel single/all orders, multi-pair orderbook depth.
    • Expanded trading: recent swaps with advanced filters, active swaps with status, trade preimage, cancel swap, max/min trading volume.
    • Enhanced data support: precise fractional/rational amounts across orders, swaps, and fees.
  • Refactor

    • Updated parameters and types for set/best order flows and Lightning methods for clearer, stricter inputs.
  • Chores

    • Added rational dependency and dependency overrides for examples.

cursoragent and others added 20 commits August 10, 2025 15:39
Co-authored-by: charl <charl@vanstaden.info>
…s, orderbook namespace, set_order) and sync types
…w RPC methods (lightning, orderbook, trading); reference KDF API semantics
TODO: Refactoring and docs
* Add swap manager interface for consistent swap and orderbook operations

Co-authored-by: charl <charl@vanstaden.info>

* feat(rpc): expand swap-related types

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…s/komodo_defi_rpc_methods) changes from cursor/build-swap-manager-in-sdk-0a9c relative to dev
Copilot AI review requested due to automatic review settings August 15, 2025 17:07
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 15, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

Adds new RPC request/response modules (Lightning, Orderbook, Trading), updates namespaces and method signatures, introduces numeric primitives (Fraction, MM2 Rational) and integrates them across models, expands public exports, adds new data structures, tightens JSON parsing types, adjusts existing flows (e.g., channels listing), and updates tests and example overrides.

Changes

Cohort / File(s) Summary
Example overrides
packages/dragon_charts_flutter/example/pubspec_overrides.yaml, packages/dragon_logs/example/pubspec_overrides.yaml, packages/komodo_defi_sdk/example/pubspec_overrides.yaml
Add Melos-managed dependency_overrides pointing to local package paths.
Freezed copyWith enhancement
packages/komodo_defi_local_auth/lib/src/trezor/trezor_initialization_state.freezed.dart
Enable nested copyWith for deviceInfo via added getters/implementations.
Typed JSON parsing tweaks
...activation_params/activation_params.dart, ...activation_params/tendermint_activation_params.dart, ...tendermint/enable_tendermint_with_assets.dart, ...tendermint/task_enable_tendermint_status.dart, ...transaction_history/my_tx_history.dart, ...wallet/get_private_keys.dart
Switch List casts to typed JsonList/List, use function tear-offs; no public signature changes.
Common structures: exports and new primitives
.../common_structures/common_structures.dart, .../networks/lightning/channel/channels_index.dart, .../orderbook/request_by.dart, .../primitive/fraction.dart, .../primitive/mm2_rational.dart
Add exports; introduce RequestBy, Fraction, MM2 rational helpers; re-export lightning channel filters/options.
Orderbook model extensions
.../orderbook/order_info.dart
Add optional Fraction/Rational fields for price/min/max volumes; update (de)serialization.
Trading models updates
.../trading/order_status.dart, .../trading/swap_info.dart, .../trading/swap_method.dart
Add Fraction/Rational fields to MyOrderInfo and SwapInfo; refine SwapMethod.toJson return type; doc/format tweaks.
Lightning RPC: new/changed endpoints
.../lightning/close_channel.dart, .../generate_invoice.dart, .../get_channel_details.dart, .../get_channels.dart, .../get_claimable_balances.dart, .../get_payment_history.dart, .../list_closed_channels_by_filter.dart, .../open_channel.dart, .../pay_invoice.dart, .../lightning/lightning_rpc_namespace.dart
Add multiple request/response pairs; change methods/endpoints and signatures (open/close channel, invoice/payment); simplify channels listing to open-only; extend namespace with new methods.
Orderbook RPC additions/refactors
.../orderbook/best_orders.dart, .../orderbook/cancel_all_orders.dart, .../orderbook/cancel_order.dart, .../orderbook/my_orders.dart, .../orderbook/orderbook.dart, .../orderbook/orderbook_depth.dart, .../orderbook/orderbook_rpc_namespace.dart, .../orderbook/set_order.dart
Add new RPCs (best_orders, my_orders, cancel* , depth); change CancelOrdersType fields (ticker/base/rel); update SetOrderRequest fields/types; update namespace signatures.
Trading RPC additions/changes
.../trading/active_swaps.dart, .../trading/cancel_swap.dart, .../trading/max_taker_volume.dart, .../trading/min_trading_volume.dart, .../trading/recent_swaps.dart, .../trading/start_swap.dart, .../trading/trade_preimage.dart, .../trading/trading_rpc_namespace.dart
Add/modify RPCs and models; include status maps for active swaps; add RecentSwapsFilter; extend TradePreimage; add cancel/max/min volume; add MatchBy to swaps.
RPC barrel exports
.../rpc_methods/rpc_methods.dart
Re-export newly added Lightning/Orderbook/Trading RPC modules.
Types package additions
packages/komodo_defi_types/lib/komodo_defi_types.dart, packages/komodo_defi_types/lib/src/types.dart, packages/komodo_defi_types/lib/src/trading/swap_types.dart
Add swap/trading high-level types and export them from barrels.
Dependencies and tests
packages/komodo_defi_rpc_methods/pubspec.yaml, packages/komodo_defi_rpc_methods/test/trade_preimage_rational_test.dart
Add rational dependency; add tests verifying MM2 rational round-trips for preimage models.

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant Namespace as LightningMethodsNamespace
  participant Request as RPC Request
  participant Node as MM2 RPC Node
  participant Response as Parsed Response

  App->>Namespace: generateInvoice(coin, description, amountMsat?)
  Namespace->>Request: Build GenerateInvoiceRequest
  Request->>Node: toJson() payload
  Node-->>Request: JSON result (invoice, payment_hash)
  Request-->>Namespace: GenerateInvoiceResponse.parse(...)
  Namespace-->>App: GenerateInvoiceResponse
Loading
sequenceDiagram
  participant App
  participant Namespace as OrderbookMethodsNamespace
  participant Request as BestOrdersRequest
  participant Node as MM2 RPC Node

  App->>Namespace: bestOrders(coin, action, requestBy, excludeMine?)
  Namespace->>Request: Build BestOrdersRequest
  Request->>Node: toJson() with request_by
  Node-->>Request: JSON orders[]
  Request-->>Namespace: BestOrdersResponse.parse(...)
  Namespace-->>App: BestOrdersResponse(orders)
Loading
sequenceDiagram
  participant App
  participant Namespace as TradingMethodsNamespace
  participant Req as TradePreimageRequest
  participant Node as MM2 RPC Node
  participant Res as TradePreimageResponse

  App->>Namespace: tradePreimage(base, rel, swapMethod, volume?, max?, price?)
  Namespace->>Req: Construct request
  Req->>Node: Submit RPC
  Node-->>Req: fees payload (per-coin + totals)
  Req-->>Namespace: parse -> TradePreimageResponse
  Namespace-->>App: response with totals/fees
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120+ minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • smk762

Poem

I thump my paw—new routes abound!
Fractions dance, rationals resound.
Lightning hums with channels bright,
Order books align just right.
Swaps now sing in typed delight—
Heap of hops, a happy byte.
Carrot-clicks deploy tonight! 🥕⚡️

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/only-types-and-rpc-from-0a9c

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

❤️ Share
🪧 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>, please review it.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extracts specific types and RPC changes from a larger branch, focusing only on additions to komodo_defi_types and komodo_defi_rpc_methods packages. The changes introduce high-level trading/swap types and various new RPC methods, while also including some code quality improvements.

  • Addition of comprehensive trading/swap types for SDK usage (order management, swap progress, etc.)
  • Introduction of new RPC methods for trading, Lightning Network, and orderbook operations
  • Code improvements including better type safety and cleaner syntax

Reviewed Changes

Copilot reviewed 39 out of 40 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/komodo_defi_types/lib/src/trading/swap_types.dart New comprehensive trading types for orders, swaps, and orderbook operations
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/trading/*.dart New trading RPC methods (trade_preimage, recent_swaps, etc.)
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/lightning/*.dart New Lightning Network RPC methods
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/orderbook/*.dart New orderbook RPC methods
packages/komodo_defi_rpc_methods/pubspec.yaml Added rational package dependency
Various other files Type safety improvements and syntax cleanup

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@CharlVS CharlVS changed the title Keep only types and RPC changes from cursor/build-swap-manager-in-sdk-0a9c chore(repo): keep only types and RPC changes from cursor/build-swap-manager-in-sdk-0a9c Aug 15, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 15, 2025

Visit the preview URL for this PR (updated for commit 65df8fd):

https://komodo-defi-sdk--pr191-cursor-only-types-an-tf2u4pas.web.app

(expires Mon, 25 Aug 2025 12:58:46 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 7f9f5ac39928f333b6e8fcefb7138575e24ed347

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Co-authored-by: charl <charl@vanstaden.info>
CharlVS and others added 6 commits August 17, 2025 15:37
Co-authored-by: charl <charl@vanstaden.info>
Co-authored-by: charl <charl@vanstaden.info>
…f06e' into cursor/only-types-and-rpc-from-0a9c

# Conflicts:
#	packages/komodo_defi_rpc_methods/lib/src/rpc_methods/trading/trade_preimage.dart
@CharlVS
Copy link
Copy Markdown
Collaborator Author

CharlVS commented Aug 18, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 18, 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.

1 similar comment
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 18, 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.

@CharlVS CharlVS changed the title chore(repo): keep only types and RPC changes from cursor/build-swap-manager-in-sdk-0a9c feat(rpc): trading-related RPCs/types Aug 18, 2025
@CharlVS CharlVS merged commit 965f2af into dev Aug 18, 2025
7 of 8 checks passed
@CharlVS CharlVS deleted the cursor/only-types-and-rpc-from-0a9c branch August 18, 2025 13:00
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