Skip to content

Conversation

@CharlVS
Copy link
Collaborator

@CharlVS CharlVS commented Aug 12, 2025

  • Add trading, Lightning, and orderbook RPC method namespaces

  • Refactor order status classes to use JsonMap and type-safe parsing

  • Refactor order status and related classes with type-safe parsing

  • Add new common structures for trading, orderbook, and Lightning

  • chore: re-generate indexes


* Add trading, Lightning, and orderbook RPC method namespaces

Co-authored-by: charl <[email protected]>

* Refactor order status classes to use JsonMap and type-safe parsing

Co-authored-by: charl <[email protected]>

* Refactor order status and related classes with type-safe parsing

Co-authored-by: charl <[email protected]>

* Add new common structures for trading, orderbook, and Lightning

Co-authored-by: charl <[email protected]>

* chore: re-generate indexes

---------

Co-authored-by: Cursor Agent <[email protected]>
@CharlVS CharlVS self-assigned this Aug 12, 2025
Copilot AI review requested due to automatic review settings August 12, 2025 20:18
@coderabbitai
Copy link
Contributor

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

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add/implement-missing-rpcs-cherry-picked

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
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 implements missing RPC method namespaces for the Komodo DeFi Framework, adding comprehensive support for trading, Lightning Network, and orderbook operations. The implementation includes new RPC method classes with type-safe parsing and refactored order status classes.

  • Adds three new RPC namespaces: trading, Lightning, and orderbook operations
  • Refactors order status classes to use JsonMap and type-safe parsing
  • Adds common structures for trading, orderbook, and Lightning Network data types

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/komodo_defi_rpc_methods/lib/src/rpc_methods_library.dart Adds new namespace getters for trading, orderbook, Lightning, and zhtlc
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/trading/trading_rpc_namespace.dart Implements comprehensive trading namespace with swap operations
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/trading/ New trading RPC methods for swap status and initiation
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/orderbook/ New orderbook RPC methods and namespace
packages/komodo_defi_rpc_methods/lib/src/rpc_methods/lightning/ New Lightning Network RPC methods and namespace
packages/komodo_defi_rpc_methods/lib/src/common_structures/ New common data structures for trading, orderbook, and Lightning operations

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

}) {
return execute(
StartSwapRequest(
rpcPass: rpcPass ?? this.rpcPass ?? '',
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Using an empty string as fallback for RPC password could lead to authentication bypass. Consider throwing an exception or returning an error when no valid RPC password is available.

Suggested change
rpcPass: rpcPass ?? this.rpcPass ?? '',
final effectiveRpcPass = rpcPass ?? this.rpcPass;
if (effectiveRpcPass == null || effectiveRpcPass.isEmpty) {
throw ArgumentError('RPC password must be provided and non-empty.');
}
return execute(
StartSwapRequest(
rpcPass: effectiveRpcPass,

Copilot uses AI. Check for mistakes.
}) {
return execute(
EnableLightningRequest(
rpcPass: rpcPass ?? this.rpcPass ?? '',
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Using an empty string as fallback for RPC password could lead to authentication bypass. Consider throwing an exception or returning an error when no valid RPC password is available.

Suggested change
rpcPass: rpcPass ?? this.rpcPass ?? '',
final effectiveRpcPass = rpcPass ?? this.rpcPass;
if (effectiveRpcPass == null) {
throw ArgumentError('RPC password must be provided for enableLightning.');
}
return execute(
EnableLightningRequest(
rpcPass: effectiveRpcPass,

Copilot uses AI. Check for mistakes.
}) {
return execute(
OrderbookRequest(
rpcPass: rpcPass ?? this.rpcPass ?? '',
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

Using an empty string as fallback for RPC password could lead to authentication bypass. Consider throwing an exception or returning an error when no valid RPC password is available.

Suggested change
rpcPass: rpcPass ?? this.rpcPass ?? '',
rpcPass: (() {
final resolvedPass = rpcPass ?? this.rpcPass;
if (resolvedPass == null || resolvedPass.isEmpty) {
throw ArgumentError('No valid RPC password provided for orderbook request.');
}
return resolvedPass;
})(),

Copilot uses AI. Check for mistakes.
@CharlVS CharlVS merged commit 6494a1b into dev Aug 12, 2025
5 of 7 checks passed
if (baseNota != null) params['base_nota'] = baseNota;
if (relConfs != null) params['rel_confs'] = relConfs;
if (relNota != null) params['rel_nota'] = relNota;

Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect Parameter Types in SetOrderRequest

The SetOrderRequest class serializes parameters with incorrect types for the setprice RPC. minVolume (declared as bool?) is sent as the string 'true'/'false', but the API expects a numeric volume string. Similarly, baseConfs/relConfs and baseNota/relNota are declared and serialized as strings, but the API expects integers for confirmations and booleans for NOTA flags, respectively. This type mismatch causes setprice requests to be rejected or misinterpreted, preventing order placement.

Fix in Cursor Fix in Web

: null,
);
}

Copy link

Choose a reason for hiding this comment

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

Bug: JSON Parsing Fails for Custom Types

In OrderMatchBy.fromJson, the data field's presence check json.valueOrNull<OrderMatchByData?>('data') is flawed. This method attempts to cast the raw JSON map directly to OrderMatchByData, which always fails as it doesn't deserialize custom types. Consequently, the data field is always parsed as null, even when valid match_by details are present in the JSON. This silently drops critical order matching information, leading to UIs and logic receiving incomplete data.

Fix in Cursor Fix in Web

@CharlVS CharlVS deleted the add/implement-missing-rpcs-cherry-picked branch August 12, 2025 20:25
@CharlVS CharlVS restored the add/implement-missing-rpcs-cherry-picked branch August 12, 2025 20:27
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.

2 participants