-
Notifications
You must be signed in to change notification settings - Fork 512
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
fix: make transaction-generating scripts more robust #2690
Conversation
@CodeRabbit full review |
@coderabbitai full review |
Actions performedFull review triggered. |
WalkthroughThe changes involve updates to the Changes
Suggested reviewers
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
@coderabbitai full review |
Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
packages/xrpl/tools/generateModels.js (1)
263-263
: Suggestion: Create GitHub issues to track the planned improvements.The TODO comment indicates valuable planned improvements to add docstrings and integration tests. To ensure these tasks are properly tracked and prioritized, consider creating GitHub issues for each item:
- Add docstrings to the transaction models to improve code documentation and maintainability.
- Implement integration tests for the transaction models to enhance the robustness and reliability of the system.
This will help maintain visibility on these important enhancements and allow for better collaboration and progress tracking.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/xrpl/tools/createValidateTests.js (3 hunks)
- packages/xrpl/tools/generateModels.js (2 hunks)
Additional comments not posted (4)
packages/xrpl/tools/createValidateTests.js (2)
14-14
: Verify the impact of replacing the error throw with a placeholder return.The change replaces the error throw with a return statement that provides a placeholder string. This alters the function's behavior when no valid transactions are found for the given
txName
. Instead of terminating with an error, the function now returns a default value.Please ensure that the calling code is equipped to handle this change in behavior appropriately. Additionally, consider providing a more informative placeholder or comment to guide the user on adding a sample transaction.
77-77
: Verify the impact of replacing error throws with placeholder comments.The changes replace error throws with return statements that provide placeholder comments for unsupported parameter types. This modifies the function's behavior by allowing it to return non-error values instead of terminating execution when encountering unsupported types.
Please ensure that the calling code is prepared to handle these placeholder values appropriately. Consider providing more specific placeholders or comments to indicate the unsupported parameter types encountered. This will aid in identifying and addressing any gaps in parameter type handling.
Also applies to: 89-89
packages/xrpl/tools/generateModels.js (2)
251-255
: LGTM!The conditional check before writing the validation tests file is a good addition. It prevents the creation of empty test files, improving the quality and maintainability of the test suite.
52-55
: Verify consistent usage of the updated transaction type terminology.The change in the regex pattern from
Transaction
toSubmittableTransaction
is appropriate. Please ensure that this updated terminology is consistently used throughout the codebase and documentation to maintain clarity.Run the following script to verify the usage of the updated terminology:
Verification successful
Clarification on SubmittableTransaction usage and its impact
The change from 'Transaction' to 'SubmittableTransaction' has been implemented, but it's not a complete replacement. Instead, it's a refinement that provides more specificity when needed. Here's a summary of the findings:
- 'SubmittableTransaction' is now defined as a union of all transaction types that can be submitted by clients.
- 'Transaction' still exists and is defined as a union of 'SubmittableTransaction' and 'PseudoTransaction'.
- 'PseudoTransaction' includes transactions that can only be created by validators.
- Most of the codebase, including the 'validate' function, still uses the broader 'Transaction' type.
The impact of this change is minimal:
- Existing code using 'Transaction' should continue to work as before.
- Developers now have the option to use 'SubmittableTransaction' when they specifically want to work with client-submittable transactions.
- This change improves type safety and clarity in scenarios where only submittable transactions should be used.
To maintain consistency, you may want to review usage of 'Transaction' throughout the codebase and consider using 'SubmittableTransaction' where appropriate, especially in client-facing APIs or functions specifically dealing with submittable transactions.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify consistent usage of `SubmittableTransaction` terminology. # Test: Search for the old `Transaction` terminology. Expect: No occurrences. rg --type typescript $'export type Transaction' # Test: Search for the new `SubmittableTransaction` terminology. Expect: Only occurrences of the new terminology. rg --type typescript $'export type SubmittableTransaction'Length of output: 178
Script:
#!/bin/bash # Description: Verify consistent usage of `SubmittableTransaction` terminology without relying on file type recognition. # Search for the old `Transaction` terminology in relevant directories echo "Searching for 'export type Transaction':" rg 'export type Transaction' packages/xrpl # Search for the new `SubmittableTransaction` terminology in relevant directories echo "Searching for 'export type SubmittableTransaction':" rg 'export type SubmittableTransaction' packages/xrpl # Search for any remaining usage of 'Transaction' type to ensure complete migration echo "Searching for any remaining 'Transaction' type usage:" rg 'Transaction(?!.*SubmittableTransaction)' packages/xrplLength of output: 1196
Script:
#!/bin/bash # Description: Search for remaining 'Transaction' usages without complex regex echo "Searching for remaining 'Transaction' usages:" rg 'Transaction' packages/xrpl --type ts --type jsLength of output: 143709
Script:
#!/bin/bash # Description: Examine the content of the transaction.ts file echo "Content of packages/xrpl/src/models/transactions/transaction.ts:" cat packages/xrpl/src/models/transactions/transaction.tsLength of output: 10920
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
packages/xrpl/tools/generateModels.js (2)
251-255
: Use braces for the 'if' statement to improve readability.It's recommended to use curly braces
{}
withif
statements, even when there is only a single statement inside. This enhances code readability and reduces the risk of errors during future modifications.Apply this diff to include braces:
if (validateTests !== '') { fs.writeFileSync( path.join(path.dirname(__filename), `../test/models/${tx}.test.ts`), validateTests, ) - ) +}
263-263
: Address the TODO: Add docstrings and integration tests.There's a
TODO
comment indicating the need to add docstrings to the models and integration tests. Completing this task will improve code documentation and ensure that the models are thoroughly tested in real-world scenarios.Would you like assistance in generating the docstrings and setting up the integration tests? I can help create a template or open a new GitHub issue to track this task.
High Level Overview of Change
Title says it all.
Context of Change
There were some issues when working on price oracle.
Type of Change
Did you update HISTORY.md?
Test Plan
Tested locally.