Skip to content
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

Feature/mpt v1 -testingcoderabbit #4

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

bachase
Copy link
Owner

@bachase bachase commented Sep 15, 2024

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration file for managing code reviews and automated checks.
    • Added support for multi-party tokens (MPT) including issuance and management functionalities.
    • Enhanced the protocol with new transaction types and error codes related to MPT.
    • Implemented flexible amount handling with the new STEitherAmount type.
    • Added new functions for handling 192-bit values and improved serialization capabilities.
  • Bug Fixes

    • Improved error handling for multi-party token transactions.
  • Documentation

    • Updated JSON field declarations to support new MPT features.
  • Refactor

    • Streamlined amount handling and introduced new utility functions for MPT operations.
    • Enhanced the STObject class to manage variant fields more effectively.

gregtatcam and others added 4 commits August 27, 2024 13:14
New Transactions:
- MPTokenIssuanceCreate
- MPTokenIssuanceDestory
- MPTokenIssuanceSet
- MPTokenAuthorize

Modified Transactions:
- Payment
- Clawback

New Objects:
- MPTokenIssuance
- MPTokenAuthorize

API updates:
- ledger_entry
- account_objects
- ledger_data

Read full spec: https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0033d-multi-purpose-tokens

---------

Co-authored-by: Shawn Xie <shawnxie920@gmail.com>
Co-authored-by: Howard Hinnant <howard.hinnant@gmail.com>
* add issuance not found code

* add issuance check to start of func

* uses `exists()`
* fix maximum amt

* add if check to return tecMPT_ISSUANCE_NOT_FOUND
Copy link

coderabbitai bot commented Sep 15, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between 23991c9 and 88f4f26.

Files ignored due to path filters (77)
  • Builds/levelization/results/loops.txt is excluded by !**/*.txt
  • src/test/app/AMMExtended_test.cpp is excluded by !src/test/**
  • src/test/app/Check_test.cpp is excluded by !src/test/**
  • src/test/app/Clawback_test.cpp is excluded by !src/test/**
  • src/test/app/Flow_test.cpp is excluded by !src/test/**
  • src/test/app/MPToken_test.cpp is excluded by !src/test/**
  • src/test/app/Offer_test.cpp is excluded by !src/test/**
  • src/test/app/Path_test.cpp is excluded by !src/test/**
  • src/test/app/PayChan_test.cpp is excluded by !src/test/**
  • src/test/app/TheoreticalQuality_test.cpp is excluded by !src/test/**
  • src/test/app/XChain_test.cpp is excluded by !src/test/**
  • src/test/jtx.h is excluded by !src/test/**
  • src/test/jtx/Env.h is excluded by !src/test/**
  • src/test/jtx/amount.h is excluded by !src/test/**
  • src/test/jtx/attester.h is excluded by !src/test/**
  • src/test/jtx/delivermin.h is excluded by !src/test/**
  • src/test/jtx/impl/AMMTest.cpp is excluded by !src/test/**
  • src/test/jtx/impl/amount.cpp is excluded by !src/test/**
  • src/test/jtx/impl/attester.cpp is excluded by !src/test/**
  • src/test/jtx/impl/envconfig.cpp is excluded by !src/test/**
  • src/test/jtx/impl/mpt.cpp is excluded by !src/test/**
  • src/test/jtx/impl/offer.cpp is excluded by !src/test/**
  • src/test/jtx/impl/paths.cpp is excluded by !src/test/**
  • src/test/jtx/impl/trust.cpp is excluded by !src/test/**
  • src/test/jtx/impl/xchain_bridge.cpp is excluded by !src/test/**
  • src/test/jtx/mpt.h is excluded by !src/test/**
  • src/test/jtx/offer.h is excluded by !src/test/**
  • src/test/jtx/sendmax.h is excluded by !src/test/**
  • src/test/jtx/trust.h is excluded by !src/test/**
  • src/test/jtx/xchain_bridge.h is excluded by !src/test/**
  • src/test/protocol/STAmount_test.cpp is excluded by !src/test/**
  • src/test/protocol/STObject_test.cpp is excluded by !src/test/**
  • src/test/protocol/STTx_test.cpp is excluded by !src/test/**
  • src/test/rpc/AccountSet_test.cpp is excluded by !src/test/**
  • src/xrpld/app/ledger/detail/LedgerToJson.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/misc/NetworkOPs.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMCreate.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMDeposit.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMWithdraw.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/CashCheck.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Clawback.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Escrow.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/InvariantCheck.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/InvariantCheck.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenAuthorize.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenAuthorize.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceSet.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenMint.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenUtils.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/PayChan.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Payment.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/SetTrust.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Transactor.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/XChainBridge.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/applySteps.cpp is excluded by !src/xrpld/**
  • src/xrpld/ledger/View.h is excluded by !src/xrpld/**
  • src/xrpld/ledger/detail/View.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/DeliveredAmount.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/MPTokenIssuanceID.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/DeliveredAmount.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/MPTokenIssuanceID.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/RPCHelpers.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/TransactionSign.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/Tuning.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/AccountObjects.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/AccountTx.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/Handlers.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/LedgerData.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/LedgerEntry.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/Tx.cpp is excluded by !src/xrpld/**
Files selected for processing (48)
  • .coderabbit.yml (1 hunks)
  • include/xrpl/basics/MPTAmount.h (1 hunks)
  • include/xrpl/basics/Number.h (4 hunks)
  • include/xrpl/basics/base_uint.h (2 hunks)
  • include/xrpl/protocol/Feature.h (2 hunks)
  • include/xrpl/protocol/Indexes.h (2 hunks)
  • include/xrpl/protocol/Issue.h (1 hunks)
  • include/xrpl/protocol/LedgerFormats.h (2 hunks)
  • include/xrpl/protocol/MPTIssue.h (1 hunks)
  • include/xrpl/protocol/Protocol.h (1 hunks)
  • include/xrpl/protocol/Rate.h (2 hunks)
  • include/xrpl/protocol/SField.h (10 hunks)
  • include/xrpl/protocol/SOTemplate.h (5 hunks)
  • include/xrpl/protocol/STAmount.h (5 hunks)
  • include/xrpl/protocol/STBitString.h (2 hunks)
  • include/xrpl/protocol/STEitherAmount.h (1 hunks)
  • include/xrpl/protocol/STMPTAmount.h (1 hunks)
  • include/xrpl/protocol/STObject.h (26 hunks)
  • include/xrpl/protocol/Serializer.h (2 hunks)
  • include/xrpl/protocol/TER.h (3 hunks)
  • include/xrpl/protocol/TxFlags.h (3 hunks)
  • include/xrpl/protocol/TxFormats.h (1 hunks)
  • include/xrpl/protocol/TxMeta.h (2 hunks)
  • include/xrpl/protocol/UintTypes.h (2 hunks)
  • include/xrpl/protocol/XChainAttestations.h (2 hunks)
  • include/xrpl/protocol/jss.h (4 hunks)
  • src/libxrpl/basics/MPTAmount.cpp (1 hunks)
  • src/libxrpl/basics/Number.cpp (1 hunks)
  • src/libxrpl/protocol/Feature.cpp (1 hunks)
  • src/libxrpl/protocol/Indexes.cpp (3 hunks)
  • src/libxrpl/protocol/Issue.cpp (1 hunks)
  • src/libxrpl/protocol/LedgerFormats.cpp (1 hunks)
  • src/libxrpl/protocol/MPTIssue.cpp (1 hunks)
  • src/libxrpl/protocol/Rate2.cpp (1 hunks)
  • src/libxrpl/protocol/SField.cpp (7 hunks)
  • src/libxrpl/protocol/STAmount.cpp (9 hunks)
  • src/libxrpl/protocol/STEitherAmount.cpp (1 hunks)
  • src/libxrpl/protocol/STMPTAmount.cpp (1 hunks)
  • src/libxrpl/protocol/STObject.cpp (3 hunks)
  • src/libxrpl/protocol/STParsedJSON.cpp (2 hunks)
  • src/libxrpl/protocol/STTx.cpp (2 hunks)
  • src/libxrpl/protocol/STVar.cpp (2 hunks)
  • src/libxrpl/protocol/Serializer.cpp (1 hunks)
  • src/libxrpl/protocol/TER.cpp (3 hunks)
  • src/libxrpl/protocol/TxFormats.cpp (3 hunks)
  • src/libxrpl/protocol/TxMeta.cpp (1 hunks)
  • src/libxrpl/protocol/UintTypes.cpp (2 hunks)
  • src/libxrpl/protocol/XChainAttestations.cpp (11 hunks)
__________________________________________________
< I want to be a VS Code extension when I grow up. >
--------------------------------------------------
 \
  \   \
       \ /\
       ( )
     .( o ).

Walkthrough

The changes introduce a comprehensive update to the XRPL protocol, enhancing its capabilities with the addition of multi-party tokens (MPT). Key modifications include new classes for handling MPT amounts and issuances, updates to existing classes to support flexible amount representations, and the introduction of new transaction types and flags related to MPT functionalities. Configuration files have also been updated to streamline code reviews and automated checks, ensuring better code quality and communication within development teams.

Changes

File(s) Change Summary
.coderabbit.yml Introduced configuration settings for code reviews, automated checks, chat functionality, and knowledge base integration.
include/xrpl/basics/MPTAmount.h Defined MPTAmount class for handling monetary amounts with various operations and JSON serialization.
include/xrpl/basics/Number.h Added support for MPTAmount in the Number class with new constructors and conversion operators.
include/xrpl/basics/base_uint.h Added uint192 type alias for 192-bit unsigned integers.
include/xrpl/protocol/Feature.h Updated numFeatures to 80 and declared featureMPTokensV1 for new MPT functionalities.
include/xrpl/protocol/Indexes.h Introduced functions for managing MPT issuance and tokens, enhancing flexibility in token management.
include/xrpl/protocol/Issue.h Added getIssuer() method to the Issue class for retrieving issuer information.
include/xrpl/protocol/LedgerFormats.h Added new ledger entry types for MPTOKEN_ISSUANCE and MPTOKEN, including associated flags.
include/xrpl/protocol/MPTIssue.h Defined MPTIssue class for handling MPT issuance with relevant methods and JSON serialization.
include/xrpl/protocol/Protocol.h Introduced constants for MPToken metadata length and maximum issuance amount.
include/xrpl/protocol/Rate.h Added multiply function for STMPTAmount to handle rate calculations.
include/xrpl/protocol/SField.h Introduced STEitherAmount class for flexible amount representation and updated relevant fields.
include/xrpl/protocol/STEitherAmount.h Defined STEitherAmount class to handle either STAmount or STMPTAmount, enhancing type safety.
include/xrpl/protocol/STMPTAmount.h Defined STMPTAmount class for managing amounts linked to specific MPT issues.
include/xrpl/protocol/STObject.h Updated to support STEitherAmount for flexible amount handling.
include/xrpl/protocol/TxFlags.h Added new transaction flags for MPToken functionalities, refining transaction logic.
include/xrpl/protocol/TxFormats.h Introduced new transaction types for managing MPTokenIssuance.
include/xrpl/protocol/TxMeta.h Updated to use STEitherAmount for delivered amounts in transaction metadata.
include/xrpl/protocol/UintTypes.h Introduced MPTID type for 192-bit identifiers.
src/libxrpl/basics/MPTAmount.cpp Implemented arithmetic and comparison operations for MPTAmount.
src/libxrpl/protocol/Feature.cpp Registered the new MPTokensV1 feature in the protocol.
src/libxrpl/protocol/Indexes.cpp Implemented functions for MPT management and keylet creation.
src/libxrpl/protocol/Issue.cpp Added getIssuer() method to the Issue class.
src/libxrpl/protocol/LedgerFormats.cpp Added MPTokenIssuance and MPToken types with required fields.
src/libxrpl/protocol/MPTIssue.cpp Defined methods for MPTIssue and JSON serialization.
src/libxrpl/protocol/Rate2.cpp Added multiply function for STMPTAmount handling.
src/libxrpl/protocol/SField.cpp Enhanced field handling with new constants and updated types for amounts.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant CI/CD
    participant CodeReviewTool
    participant ProjectManagementTool

    Developer->>CodeReviewTool: Submit code changes
    CodeReviewTool->>CI/CD: Trigger automated checks
    CI/CD->>CodeReviewTool: Run linting and analysis tools
    CodeReviewTool->>ProjectManagementTool: Update issue tracking
    ProjectManagementTool->>Developer: Notify review status
Loading

🐰 In the code garden, changes bloom bright,
New tokens and amounts take flight.
With MPTs and features galore,
The protocol's magic opens new doors!
Hopping along, we celebrate this cheer,
For every line of code, we hold dear!
Let's code and create, with joy and delight! 🌟

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting in your project's settings in CodeRabbit to generate walkthrough in a markdown collapsible section.


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?

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>.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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

Documentation and Community

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

@bachase
Copy link
Owner Author

bachase commented Sep 15, 2024

@coderabbitai configuration

Copy link

coderabbitai bot commented Sep 15, 2024

CodeRabbit configuration
language: en-US
tone_instructions: ''
early_access: false
enable_free_tier: true
reviews:
  profile: chill
  request_changes_workflow: false
  high_level_summary: true
  high_level_summary_placeholder: '@coderabbitai summary'
  auto_title_placeholder: '@coderabbitai'
  review_status: true
  poem: true
  collapse_walkthrough: false
  sequence_diagrams: true
  labeling_instructions: []
  path_filters: []
  path_instructions: []
  abort_on_close: true
  auto_review:
    enabled: true
    auto_incremental_review: true
    ignore_title_keywords: []
    labels: []
    drafts: false
    base_branches: []
  tools:
    shellcheck:
      enabled: true
    ruff:
      enabled: true
    markdownlint:
      enabled: true
    github-checks:
      enabled: true
      timeout_ms: 90000
    languagetool:
      enabled: true
      enabled_only: false
      level: default
    biome:
      enabled: true
    hadolint:
      enabled: true
    swiftlint:
      enabled: true
    phpstan:
      enabled: true
      level: default
    golangci-lint:
      enabled: true
    yamllint:
      enabled: true
    gitleaks:
      enabled: true
    checkov:
      enabled: true
    detekt:
      enabled: true
    eslint:
      enabled: true
    rubocop:
      enabled: true
    buf:
      enabled: true
    regal:
      enabled: true
    actionlint:
      enabled: true
    pmd:
      enabled: true
    cppcheck:
      enabled: true
chat:
  auto_reply: true
knowledge_base:
  opt_out: false
  learnings:
    scope: auto
  issues:
    scope: auto
  jira:
    project_keys: []
  linear:
    team_keys: []
  pull_requests:
    scope: auto

@bachase
Copy link
Owner Author

bachase commented Sep 15, 2024

@coderabbitai full review

Copy link

coderabbitai bot commented Sep 15, 2024

Actions performed

Full review triggered.

Copy link

@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: 4

Outside diff range and nitpick comments (5)
.coderabbit.yml (3)

1-2: Consider providing tone instructions for better customization.

Setting the language to en-US is a good practice for consistency. However, the tone_instructions field is empty. Consider providing specific instructions to customize the AI's tone to better suit your project's needs.


5-29: Review settings are mostly good, but consider a stricter review profile if needed.

The enabled review features, such as high-level summaries, auto titles, review status, poems, and sequence diagrams, provide useful enhancements to the review process.

The path filters help focus the reviews on the most relevant files by excluding less important ones, which is a good practice.

Enabling auto-review with incremental reviews helps streamline the review process, which is beneficial.

However, the "chill" review profile indicates a more lenient review style. Depending on your project's needs, consider using a stricter profile to ensure thorough reviews.


76-89: Chat and knowledge base settings are good, but complete the Jira and Linear integration.

Enabling auto-reply for chat can help provide quick responses to common questions or issues, which is a useful feature.

Enabling the knowledge base with automatic scope for learnings, issues, and pull requests allows the AI to continuously learn and improve from the project's data, which is a great way to leverage the AI's capabilities.

Configuring integration with Jira and Linear is a good step towards better project management. However, the project_keys and team_keys fields are empty, indicating that the integration is not fully set up yet. To complete the integration, provide the necessary keys for your Jira and Linear projects.

include/xrpl/basics/MPTAmount.h (1)

155-181: LGTM, but consider adding a test case!

The mulRatio function is well-implemented and handles the multiplication of an MPTAmount by a ratio correctly. The use of boost::multiprecision::int128_t for intermediate calculations is a good choice to avoid overflow. The function also properly checks for division by zero and overflow, throwing exceptions in those cases.

Consider adding a test case to verify the behavior of the overflow check, ensuring that an exception is thrown when the result exceeds the maximum value of MPTAmount.

include/xrpl/protocol/STAmount.h (1)

450-452: Nice addition of the operator<< overload for improved usability.

The new operator<< overload for STAmount enhances the usability of the class by allowing output to ostream. This change improves the logging and debugging capabilities of the class, making it easier to inspect STAmount instances.

Please provide more information on how the output is formatted in the operator<< implementation to ensure that it provides meaningful and readable information.

Consider adding a code comment or documentation describing the expected output format of the operator<< overload for clarity.

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 23991c9 and 88f4f26.

Files ignored due to path filters (77)
  • Builds/levelization/results/loops.txt is excluded by !**/*.txt
  • src/test/app/AMMExtended_test.cpp is excluded by !src/test/**
  • src/test/app/Check_test.cpp is excluded by !src/test/**
  • src/test/app/Clawback_test.cpp is excluded by !src/test/**
  • src/test/app/Flow_test.cpp is excluded by !src/test/**
  • src/test/app/MPToken_test.cpp is excluded by !src/test/**
  • src/test/app/Offer_test.cpp is excluded by !src/test/**
  • src/test/app/Path_test.cpp is excluded by !src/test/**
  • src/test/app/PayChan_test.cpp is excluded by !src/test/**
  • src/test/app/TheoreticalQuality_test.cpp is excluded by !src/test/**
  • src/test/app/XChain_test.cpp is excluded by !src/test/**
  • src/test/jtx.h is excluded by !src/test/**
  • src/test/jtx/Env.h is excluded by !src/test/**
  • src/test/jtx/amount.h is excluded by !src/test/**
  • src/test/jtx/attester.h is excluded by !src/test/**
  • src/test/jtx/delivermin.h is excluded by !src/test/**
  • src/test/jtx/impl/AMMTest.cpp is excluded by !src/test/**
  • src/test/jtx/impl/amount.cpp is excluded by !src/test/**
  • src/test/jtx/impl/attester.cpp is excluded by !src/test/**
  • src/test/jtx/impl/envconfig.cpp is excluded by !src/test/**
  • src/test/jtx/impl/mpt.cpp is excluded by !src/test/**
  • src/test/jtx/impl/offer.cpp is excluded by !src/test/**
  • src/test/jtx/impl/paths.cpp is excluded by !src/test/**
  • src/test/jtx/impl/trust.cpp is excluded by !src/test/**
  • src/test/jtx/impl/xchain_bridge.cpp is excluded by !src/test/**
  • src/test/jtx/mpt.h is excluded by !src/test/**
  • src/test/jtx/offer.h is excluded by !src/test/**
  • src/test/jtx/sendmax.h is excluded by !src/test/**
  • src/test/jtx/trust.h is excluded by !src/test/**
  • src/test/jtx/xchain_bridge.h is excluded by !src/test/**
  • src/test/protocol/STAmount_test.cpp is excluded by !src/test/**
  • src/test/protocol/STObject_test.cpp is excluded by !src/test/**
  • src/test/protocol/STTx_test.cpp is excluded by !src/test/**
  • src/test/rpc/AccountSet_test.cpp is excluded by !src/test/**
  • src/xrpld/app/ledger/detail/LedgerToJson.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/misc/NetworkOPs.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMCreate.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMDeposit.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/AMMWithdraw.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/CashCheck.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Clawback.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Escrow.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/InvariantCheck.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/InvariantCheck.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenAuthorize.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenAuthorize.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/MPTokenIssuanceSet.h is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenMint.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/NFTokenUtils.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/PayChan.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Payment.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/SetTrust.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/Transactor.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/XChainBridge.cpp is excluded by !src/xrpld/**
  • src/xrpld/app/tx/detail/applySteps.cpp is excluded by !src/xrpld/**
  • src/xrpld/ledger/View.h is excluded by !src/xrpld/**
  • src/xrpld/ledger/detail/View.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/DeliveredAmount.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/MPTokenIssuanceID.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/DeliveredAmount.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/MPTokenIssuanceID.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/RPCHelpers.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/TransactionSign.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/detail/Tuning.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/AccountObjects.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/AccountTx.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/Handlers.h is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/LedgerData.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/LedgerEntry.cpp is excluded by !src/xrpld/**
  • src/xrpld/rpc/handlers/Tx.cpp is excluded by !src/xrpld/**
Files selected for processing (48)
  • .coderabbit.yml (1 hunks)
  • include/xrpl/basics/MPTAmount.h (1 hunks)
  • include/xrpl/basics/Number.h (4 hunks)
  • include/xrpl/basics/base_uint.h (2 hunks)
  • include/xrpl/protocol/Feature.h (2 hunks)
  • include/xrpl/protocol/Indexes.h (2 hunks)
  • include/xrpl/protocol/Issue.h (1 hunks)
  • include/xrpl/protocol/LedgerFormats.h (2 hunks)
  • include/xrpl/protocol/MPTIssue.h (1 hunks)
  • include/xrpl/protocol/Protocol.h (1 hunks)
  • include/xrpl/protocol/Rate.h (2 hunks)
  • include/xrpl/protocol/SField.h (10 hunks)
  • include/xrpl/protocol/SOTemplate.h (5 hunks)
  • include/xrpl/protocol/STAmount.h (5 hunks)
  • include/xrpl/protocol/STBitString.h (2 hunks)
  • include/xrpl/protocol/STEitherAmount.h (1 hunks)
  • include/xrpl/protocol/STMPTAmount.h (1 hunks)
  • include/xrpl/protocol/STObject.h (26 hunks)
  • include/xrpl/protocol/Serializer.h (2 hunks)
  • include/xrpl/protocol/TER.h (3 hunks)
  • include/xrpl/protocol/TxFlags.h (3 hunks)
  • include/xrpl/protocol/TxFormats.h (1 hunks)
  • include/xrpl/protocol/TxMeta.h (2 hunks)
  • include/xrpl/protocol/UintTypes.h (2 hunks)
  • include/xrpl/protocol/XChainAttestations.h (2 hunks)
  • include/xrpl/protocol/jss.h (4 hunks)
  • src/libxrpl/basics/MPTAmount.cpp (1 hunks)
  • src/libxrpl/basics/Number.cpp (1 hunks)
  • src/libxrpl/protocol/Feature.cpp (1 hunks)
  • src/libxrpl/protocol/Indexes.cpp (3 hunks)
  • src/libxrpl/protocol/Issue.cpp (1 hunks)
  • src/libxrpl/protocol/LedgerFormats.cpp (1 hunks)
  • src/libxrpl/protocol/MPTIssue.cpp (1 hunks)
  • src/libxrpl/protocol/Rate2.cpp (1 hunks)
  • src/libxrpl/protocol/SField.cpp (7 hunks)
  • src/libxrpl/protocol/STAmount.cpp (9 hunks)
  • src/libxrpl/protocol/STEitherAmount.cpp (1 hunks)
  • src/libxrpl/protocol/STMPTAmount.cpp (1 hunks)
  • src/libxrpl/protocol/STObject.cpp (3 hunks)
  • src/libxrpl/protocol/STParsedJSON.cpp (2 hunks)
  • src/libxrpl/protocol/STTx.cpp (2 hunks)
  • src/libxrpl/protocol/STVar.cpp (2 hunks)
  • src/libxrpl/protocol/Serializer.cpp (1 hunks)
  • src/libxrpl/protocol/TER.cpp (3 hunks)
  • src/libxrpl/protocol/TxFormats.cpp (3 hunks)
  • src/libxrpl/protocol/TxMeta.cpp (1 hunks)
  • src/libxrpl/protocol/UintTypes.cpp (2 hunks)
  • src/libxrpl/protocol/XChainAttestations.cpp (11 hunks)
Additional comments not posted (193)
src/libxrpl/protocol/MPTIssue.cpp (5)

26-28: LGTM!

The MPTIssue class declaration and constructor look good. The class encapsulates an MPTID and initializes it through the constructor.


30-41: LGTM!

The getIssuer() function correctly extracts the issuer's account ID from the MPTID by copying the relevant data while skipping the sequence portion of the ID.


43-47: LGTM!

The getMptID() function correctly returns a constant reference to the MPTID associated with the instance, ensuring that the caller cannot modify the MPTID.


49-55: LGTM!

The to_json() function correctly converts an MPTIssue object into a JSON representation by setting the mpt_issuance_id field with the string representation of the MPTID.


24-57: LGTM!

The code is correctly wrapped within the ripple namespace to encapsulate the MPTIssue class and related functions, helping to avoid naming conflicts with other code.

.coderabbit.yml (2)

3-4: Access and tier settings look good!

Disabling early_access ensures using stable AI features. Enabling enable_free_tier allows using the AI without a paid subscription, which is suitable for many projects.


29-75: Great selection of tools! Remember to keep them updated.

Enabling a wide range of linting and analysis tools, such as ShellCheck, Ruff, MarkdownLint, ESLint, RuboCop, and others, helps ensure code quality and consistency across different languages and aspects of the project, which is a great practice.

Customizing settings for some tools, like the timeout for GitHub Checks and levels for LanguageTool and PHPStan, allows fine-tuning their behavior to suit the project's needs.

To make the most out of these tools, remember to regularly update them to use their latest versions and features.

include/xrpl/protocol/MPTIssue.h (3)

28-49: LGTM!

The MPTIssue class is well-defined and encapsulates the necessary components for representing an MPT issue. The private member variable, constructors, and public member functions are appropriately designed to handle the MPT issue data.


51-55: LGTM!

The equality operator is correctly implemented to compare two MPTIssue instances based on their mptID_ member. The use of constexpr is appropriate for this simple comparison function.


57-61: LGTM!

The inequality operator is correctly implemented to compare two MPTIssue instances based on their mptID_ member. It leverages the equality operator and negates the result, which is a common and efficient approach.

src/libxrpl/basics/MPTAmount.cpp (8)

24-29: LGTM!

The operator+= implementation is correct and follows the expected behavior of modifying the current object and returning a reference to allow chaining.


31-36: LGTM!

The operator-= implementation is correct and follows the expected behavior of modifying the current object and returning a reference to allow chaining.


38-42: LGTM!

The unary operator- implementation is correct and follows the expected behavior of returning a new MPTAmount object with the negated value.


44-48: LGTM!

The operator== implementation is correct and follows the expected behavior of comparing the values of two MPTAmount objects and returning a boolean result.


50-54: LGTM!

The operator== overload for comparing an MPTAmount object with a value of the underlying type is correct and follows the expected behavior of comparing the values and returning a boolean result.


56-60: LGTM!

The operator< implementation is correct and follows the expected behavior of comparing the values of two MPTAmount objects and returning a boolean result indicating whether the current object's value is less than the other object's value.


62-77: LGTM!

The jsonClipped function implementation is correct and follows the expected behavior of converting the MPTAmount value to a JSON-compatible integer. It properly handles cases where the value is outside the range of Json::Int by clipping it to the minimum or maximum value. The static assertions ensure that the underlying type is a signed integral type, providing type safety.


79-83: LGTM!

The minPositiveAmount static function implementation is correct and follows the expected behavior of returning an MPTAmount object with a value of 1, representing the minimum positive value.

include/xrpl/protocol/Rate.h (2)

24-24: LGTM!

The inclusion of STMPTAmount.h is necessary for the new multiply function that takes STMPTAmount as an argument.


71-72: Approve implementation, but usage and testing concerns

The implementation of the multiply function for STMPTAmount in src/libxrpl/protocol/Rate2.cpp appears correct and consistent with the declaration. However, there are some concerns:

  1. No usage of this new function was found in the codebase.
  2. No specific test files for STMPTAmount or Rate were found.

Recommendations:

  • Add unit tests for the new multiply function to ensure its correctness and maintain code quality.
  • Review the need for this function if it's not currently being used in the codebase.
  • Consider adding documentation to explain the purpose and expected usage of this function.
Analysis chain

Verify the usage of the new multiply function in the codebase.

The new multiply function overload for STMPTAmount is a crucial addition to support operations involving the STMPTAmount type. The function declaration is consistent with the existing multiply function for STAmount.

Please run the following script to verify that the new multiply function is being used correctly in the codebase:


To gather more information about the implementation and usage of the new multiply function, let's run the following additional scripts:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `multiply` function for `STMPTAmount`.

# Test 1: Search for the function declaration.
# Expect: The function declaration should be found in this file.
rg --type cpp -A 5 $'STMPTAmount\nmultiply\(STMPTAmount const& amount, Rate const& rate\);'

# Test 2: Search for the function usage.
# Expect: The function should be called with `STMPTAmount` and `Rate` arguments.
rg --type cpp -A 5 $'multiply\(STMPTAmount'

Length of output: 1287


Script:

#!/bin/bash
# Description: Further verify the implementation and usage of the new `multiply` function for `STMPTAmount`.

# Test 1: Check the implementation of the multiply function
rg --type cpp -A 10 'multiply\(STMPTAmount const& amount, Rate const& rate\)' src/libxrpl/protocol/Rate2.cpp

# Test 2: Search for potential usage of the function (indirect search)
rg --type cpp -A 5 'STMPTAmount.*multiply'

# Test 3: Check for test files related to STMPTAmount or Rate
fd -e cpp -e h test.*STMPTAmount
fd -e cpp -e h test.*Rate

Length of output: 487

include/xrpl/protocol/Issue.h (1)

49-50: LGTM!

The new getIssuer function follows best practices:

  • It is marked as const since it does not modify the object's state.
  • It returns a const& to avoid unnecessary copying and to indicate that the returned reference cannot be used to modify the account member.

This is a straightforward addition of a getter function that improves the class's interface by providing access to the account member variable. There are no apparent issues or side effects.

src/libxrpl/protocol/Rate2.cpp (1)

57-68: LGTM!

The new multiply function for STMPTAmount types is implemented correctly and enhances the functionality of the library. The function includes appropriate checks and optimizations, such as:

  • Asserting that the rate is not zero to prevent division errors.
  • Returning the original STMPTAmount if the rate is equal to parityRate.
  • Adjusting the rate by a factor of 10^-9 during the multiplication.

The function is well-documented, follows the coding conventions, and has no apparent issues or side effects.

src/libxrpl/protocol/Issue.cpp (1)

29-33: LGTM!

The getIssuer() function is implemented correctly as a simple getter that returns a constant reference to the account member variable. The const qualifier is used appropriately, and the function provides read-only access to the account member variable, which aligns with the expected behavior of a getter function.

include/xrpl/protocol/TxMeta.h (3)

135-135: LGTM!

The change in the mDelivered member variable type to std::optional<STEitherAmount> is consistent with the overall shift in representing delivered amounts within the TxMeta class.


116-116: Ensure safe usage of getDeliveredAmount.

The change in the getDeliveredAmount method return type to STEitherAmount is consistent with the overall shift in representing delivered amounts within the TxMeta class.

To avoid potential runtime errors, callers of getDeliveredAmount should first check the presence of a delivered amount using the hasDeliveredAmount method. Please verify that all invocations of getDeliveredAmount are preceded by a check on hasDeliveredAmount. Run the following script to identify any unsafe usages:

Verification successful

getDeliveredAmount() usage is safe throughout the codebase.

After a thorough examination of the relevant files, it's confirmed that all calls to getDeliveredAmount() are properly guarded:

  • In DeliveredAmount.cpp, calls are preceded by either hasDeliveredAmount() or canHaveDeliveredAmount() checks.
  • In TxMeta.cpp, the call is guarded by a hasDeliveredAmount() check.

These safety measures ensure that getDeliveredAmount() is only called when a delivered amount is available, addressing the concern raised in the original review comment.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all invocations of `getDeliveredAmount` are preceded by a check on `hasDeliveredAmount`.

# Test: Search for the method usage. Expect: All occurrences to be preceded by a `hasDeliveredAmount` check.
rg --type cpp -A 5 $'getDeliveredAmount\(\)'

Length of output: 1111


Script:

#!/bin/bash
# Description: Check for hasDeliveredAmount() usage and examine the context of getDeliveredAmount() calls

# Check for hasDeliveredAmount() usage in DeliveredAmount.cpp
echo "Checking DeliveredAmount.cpp:"
rg --type cpp -C 10 'hasDeliveredAmount|getDeliveredAmount' src/xrpld/rpc/detail/DeliveredAmount.cpp

echo -e "\nChecking TxMeta.cpp:"
# Check for hasDeliveredAmount() usage in TxMeta.cpp
rg --type cpp -C 10 'hasDeliveredAmount|getDeliveredAmount' src/libxrpl/protocol/TxMeta.cpp

Length of output: 4585


111-111: Verify STEitherAmount usage across the codebase.

The change in the setDeliveredAmount method signature to accept STEitherAmount instead of STAmount is consistent with the overall shift in representing delivered amounts within the TxMeta class.

Please ensure that all invocations of the setDeliveredAmount method have been updated to pass an STEitherAmount argument instead of STAmount. Run the following script to verify the usage:

src/libxrpl/protocol/UintTypes.cpp (1)

129-134: LGTM!

The noMPT function is a useful addition that provides a way to retrieve a default or "no" MPTID. The implementation is correct and does not alter any existing logic.

include/xrpl/protocol/UintTypes.h (2)

61-66: LGTM!

The introduction of MPTID as a 192-bit hash is a valuable addition to the protocol. The accompanying comment provides clarity on the current uniqueness of MPTID and anticipates future changes by suggesting the use of a unique tag if more 192-bit fields are introduced. This comment ensures that the code is future-proofed and maintainable.


76-78: LGTM!

The introduction of the noMPT() function is a great addition. It provides a clear and consistent way to represent an empty MPTID throughout the codebase. Having a dedicated function for this purpose promotes code clarity, reduces the chances of errors, and improves maintainability.

include/xrpl/protocol/STBitString.h (2)

87-87: LGTM!

The addition of the STUInt192 type alias is consistent with the existing pattern and expands the range of supported data types.


140-145: Verify the usage of STI_UINT192 identifier.

The addition of the getSType() specialization for STUInt192 is consistent with the existing pattern and ensures proper serialization and deserialization of the new type.

Please ensure that the STI_UINT192 identifier is defined and used consistently across the codebase. Run the following script to verify:

Verification successful

STI_UINT192 identifier is correctly defined and used.

The verification process confirms that the STI_UINT192 identifier is properly defined in SField.h and consistently used across the codebase. Its usage in STBitString.h for the STUInt192::getSType() method is correct and aligns with the pattern used for other integer types. The identifier is also appropriately integrated into JSON parsing and variable handling processes.

The original code change adding the getSType() specialization for STUInt192 is approved and consistent with the overall implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `STI_UINT192` identifier.

# Test 1: Search for the definition of `STI_UINT192`. Expect: Exactly one occurrence.
rg --type c++ -c $'STI_UINT192'

# Test 2: Search for the usage of `STI_UINT192`. Expect: At least one occurrence (in `STUInt192::getSType()`).
rg --type c++ -c $'STI_UINT192'

Length of output: 117


Script:

#!/bin/bash
# Description: Verify the usage of `STI_UINT192` identifier using grep.

# Search for STI_UINT192 in all files, showing file names and 2 lines of context before and after each match
grep -rn -C 2 "STI_UINT192" .

# Count the total occurrences of STI_UINT192
echo "Total occurrences of STI_UINT192:"
grep -r "STI_UINT192" . | wc -l

Length of output: 1844

include/xrpl/protocol/Protocol.h (2)

98-99: LGTM!

The constant maxMPTokenMetadataLength is declared with the appropriate data type and value. The comment clearly explains its purpose, which is to define the maximum length of MPTokenMetadata. This constant helps enforce a reasonable limit on the metadata size and prevents excessive resource consumption.


101-102: LGTM!

The constant maxMPTokenAmount is declared with the appropriate data type and value. The comment clearly explains its purpose, which is to define the maximum amount of MPTokenIssuance. This constant helps enforce a reasonable limit on the token issuance amount and prevents excessive issuance. The chosen value of 0x7FFFFFFFFFFFFFFFull allows for a wide range of issuance amounts while still imposing a reasonable limit.

include/xrpl/protocol/STMPTAmount.h (2)

32-100: LGTM!

The STMPTAmount class provides a comprehensive and well-designed framework for managing monetary amounts associated with a specific issue (currency) in the context of the Ripple protocol. The class correctly handles arithmetic operations, comparisons, serialization, and deserialization, ensuring the integrity and consistency of the monetary values. The provided utility functions enhance the usability and flexibility of the class.

The implementation follows best practices and includes appropriate error handling, such as throwing exceptions when attempting to perform operations on amounts with different issues. The class is well-documented, making it easy to understand and maintain.

Overall, the STMPTAmount class is a valuable addition to the Ripple protocol, providing a robust and reliable mechanism for handling multi-party token amounts.


102-191: LGTM!

The free functions provided in this file complement the STMPTAmount class and offer additional functionality for working with monetary amounts. The arithmetic operators (operator+ and operator-) and comparison operators (operator==, operator<, operator!=, operator>, operator<=, operator>=) are implemented correctly, ensuring that operations are only performed on amounts with the same issue (currency).

The amountFromString function provides a convenient way to create an STMPTAmount object from a string representation, enhancing the usability of the class. Similarly, the multiply function allows multiplying an STMPTAmount object by a Rate object, which is useful for various calculations involving exchange rates or conversions.

The implementation of these free functions follows best practices, including appropriate error handling and throwing exceptions when necessary. The functions are well-documented, making them easy to understand and use.

Overall, the free functions are a valuable addition to the STMPTAmount class and provide a comprehensive set of tools for working with monetary amounts in the Ripple protocol.

include/xrpl/protocol/SOTemplate.h (6)

25-25: LGTM!

The #include statement for the SField.h header file is necessary and looks good.


43-44: LGTM!

The new enumeration SOETxMPTAmount is well-defined and provides a clear way to categorize the support for MPT in amount fields. The enumeration values cover the necessary cases and are named appropriately.


54-54: LGTM!

The new member variable supportMpt_ of type SOETxMPTAmount is a suitable addition to the SOElement class. It allows tracking the MPT support status for each SOElement instance.


Line range hint 56-69: LGTM!

The private member function init is a helpful addition to the SOElement class. It ensures that the sField_ member variable is useful, which is a necessary condition for the class. The error handling is appropriate, throwing a std::runtime_error with a descriptive message if the condition is not met. Marking the function as private indicates that it is an internal implementation detail.


70-90: LGTM!

The modifications to the constructors of the SOElement class are well-designed. They allow initializing the supportMpt_ member variable based on the constructor arguments, providing flexibility in creating instances with different MPT support statuses. The default values for supportMpt_ are set appropriately in each constructor. Calling the init function in each constructor ensures that the sField_ member variable is validated.


103-108: LGTM!

The new member function supportMPT is a straightforward and useful addition to the SOElement class. It provides a way to retrieve the MPT support status of an instance by returning the value of the supportMpt_ member variable. Marking the function as const correctly indicates that it does not modify the object's state.

include/xrpl/basics/MPTAmount.h (8)

38-99: LGTM!

The MPTAmount class is well-designed and provides essential operations for handling integral amounts. The use of std::int64_t as the underlying type is appropriate, and leveraging Boost library for operator overloading creates an intuitive API.


101-103: LGTM!

The constructor is properly implemented as a constexpr function, allowing it to be used in constant expressions. The explicit constructor prevents implicit conversions, which is a good practice to avoid unintended behavior.


105-109: LGTM!

The assignment operator is properly implemented as a constexpr function, allowing it to be used in constant expressions. The operator sets the value_ member to zero and returns *this, following the convention for assignment operators.


112-115: LGTM!

The conversion operator is properly implemented as an explicit and constexpr function, preventing implicit conversions and allowing it to be used in constant expressions. The operator provides a convenient way to check if the amount is non-zero.


118-122: LGTM!

The signum() method is properly implemented as a constexpr function, allowing it to be used in constant expressions. The method efficiently determines the sign of the amount using a ternary operator.


134-139: LGTM!

The operator>> is properly implemented as a free function, allowing it to be used with std::istream objects. The operator reads the value_ member from the input stream and returns the stream, following the convention for input stream operators.


142-147: LGTM!

The operator<< is properly implemented as a free function template, allowing it to be used with any std::basic_ostream type. The operator writes the value() of the MPTAmount to the output stream and returns the stream, following the convention for output stream operators.


128-132: LGTM, but use with caution!

The value() method is properly implemented as a constexpr function, allowing it to be used in constant expressions. However, as indicated by the comment, this method is intended for internal use only and should be used with caution to avoid exposing the underlying type.

To ensure that the value() method is not used externally, you can run the following script:

Verification successful

Verified: Internal usage as intended, exercise caution when modifying

The value() method of MPTAmount is indeed used internally within the XRPL codebase, primarily in ledger operations and basic MPTAmount manipulations. There's no evidence of external usage, which aligns with the intention for it to be an internal method. However, due to its use in core functionality, any modifications should be approached with caution to avoid unintended side effects.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `value()` method is not used externally.

# Test: Search for usage of the `value()` method outside the `MPTAmount` class.
#       Expect: No occurrences found.
rg --type cpp $'MPTAmount::value\(\)' | rg -v $'MPTAmount\.'

Length of output: 60


Script:

#!/bin/bash

# 1. Confirm the existence and location of the MPTAmount class
echo "Locating MPTAmount class:"
fd -e h -e cpp MPTAmount

# 2. Search for usages of MPTAmount in the codebase
echo -e "\nUsages of MPTAmount:"
rg --type cpp "MPTAmount"

# 3. Look for potential aliases or typedefs of MPTAmount
echo -e "\nPotential aliases or typedefs of MPTAmount:"
rg --type cpp "typedef.*MPTAmount|using.*=.*MPTAmount"

# 4. Search for value() method calls that might be related to MPTAmount
echo -e "\nPotential value() method calls:"
rg --type cpp "\w+\.value\(\)" -C 2

Length of output: 80438

src/libxrpl/protocol/STMPTAmount.cpp (14)

29-40: LGTM!

The constructor correctly deserializes an STMPTAmount object from a SerialIter. It performs the necessary checks and throws an exception if the serialized data does not represent an MPT amount. The deserialization logic is straightforward and efficient.


42-45: LGTM!

The constructor correctly initializes an STMPTAmount object with the provided MPTIssue and value. The implementation is straightforward and free of issues.


47-58: LGTM!

The constructor properly initializes an STMPTAmount object with the provided MPTIssue, value, and negative flag. It performs a necessary check to ensure the value is within the valid range for MPT amounts and throws an exception if not. The handling of negative amounts is correct, and the overall logic is clear and concise.


60-62: LGTM!

The constructor correctly initializes an STMPTAmount object with the provided value. The implementation is straightforward and free of issues.


64-68: LGTM!

The getSType method correctly returns the serialized type ID of the STMPTAmount class. The implementation is straightforward and free of issues.


70-78: LGTM!

The getFullText method correctly returns a string representation of the STMPTAmount object by concatenating the result of getText() with the string representation of the MPT ID. The use of reserve is a good optimization to avoid unnecessary string reallocations. The implementation is straightforward and free of issues.


80-84: LGTM!

The getText method correctly returns a string representation of the value_ member variable using std::to_string. The implementation is straightforward and free of issues.


86-91: LGTM!

The getJson method correctly returns a JSON representation of the STMPTAmount object. It creates a Json::Value object and calls setJson to populate it with the necessary fields. The use of a separate setJson method promotes code reuse and maintainability. The implementation is straightforward and free of issues.


93-98: LGTM!

The setJson method correctly populates a Json::Value object with the JSON representation of the STMPTAmount object. It sets the mpt_issuance_id and value fields using string literals for improved readability. The implementation is straightforward and free of issues.


100-109: LGTM!

The add method correctly serializes the STMPTAmount object into a Serializer object. It sets the appropriate flags based on the value_ sign using bitwise operations and serializes the absolute value of value_ to avoid redundancy. The serialization order and format are consistent with the deserialization logic in the constructor. The implementation is straightforward and free of issues.


111-115: LGTM!

The isDefault method correctly checks if the STMPTAmount object represents the default amount by comparing the value_ to 0 and the issue_ to the result of noMPT(). The use of noMPT() ensures a consistent representation of the default MPT issue. The implementation is straightforward and free of issues.


117-121: LGTM!

The getIssuer method correctly returns the issuer account ID associated with the STMPTAmount object by calling the getIssuer() method of the issue_ member variable. The implementation is straightforward and free of issues.


123-127: LGTM!

The getCurrency method correctly returns the MPT ID associated with the STMPTAmount object by calling the getMptID() method of the issue_ member variable. The implementation is straightforward and free of issues.


129-133: LGTM!

The issue method correctly returns a constant reference to the issue_ member variable. Returning a constant reference is efficient and prevents unnecessary copying. The implementation is straightforward and free of issues.

src/libxrpl/protocol/TxMeta.cpp (1)

147-147: LGTM! The change improves the flexibility of amount handling.

The update from STAmount to STEitherAmount in the dynamic cast suggests that the getAffectedAccounts function now expects and handles a broader or different set of amount representations. This change enhances the robustness of the amount handling logic, allowing the function to process affected accounts with amounts of different types correctly.

The assertion following the cast remains unchanged, ensuring that the cast is valid and STEitherAmount is a derived class of the type of field.

Overall, this modification improves the flexibility and reliability of the getAffectedAccounts function in handling diverse amount types.

src/libxrpl/protocol/STVar.cpp (4)

144-146: Approve the addition of STUInt192 support.

The change introduces support for a new unsigned integer type, STUInt192, enhancing the flexibility of the STVar class in handling various data types. This expansion of supported types may benefit existing code that relies on STVar.


203-203: Approve the change from STAmount to STEitherAmount.

This change is consistent with the modification made in the other constructor at line 136. It aligns with the evolution in how amounts are represented and processed within the system.

See the previous comment for more details on the impact of this change.


211-213: Approve the addition of STUInt192 support.

This change is consistent with the addition made in the other constructor at lines 144-146. It ensures consistency in handling STUInt192 across both constructors of STVar.

See the previous comment for more details on the benefits of supporting STUInt192.


136-136: Approve the change from STAmount to STEitherAmount.

The change indicates an evolution in how amounts are represented and processed within the system. It suggests a broader capability or different handling mechanism for amounts.

Verify the impact of this change on the codebase:

Verification successful

Approve the change from STAmount to STEitherAmount in STVar.cpp

This change is part of a planned transition to support more flexible amount representations in the XRPL protocol. STEitherAmount is a new type that can hold either an STAmount or an STMPTAmount, allowing for backwards compatibility with existing STAmount usage while introducing support for new amount types.

The modification in STVar.cpp updates the deserialization process to use the more flexible STEitherAmount, which is consistent with the overall transition strategy. This change enables the protocol to handle both traditional amounts and potentially new types of amounts (like MPT) in a unified way.

Developers should be aware that:

  • Some fields (like sfFee) will continue to always return STAmount for backwards compatibility.
  • Other fields (like sfAmount) will now return STEitherAmount, requiring explicit type checking or conversion when accessing the amount value.

This transition is being implemented gradually across the codebase, maintaining compatibility while introducing new capabilities.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `STAmount` and `STEitherAmount` in the codebase.

# Test 1: Search for the usage of `STAmount`. Expect: Occurrences in code that may need to be updated.
rg --type cpp $'STAmount'

# Test 2: Search for the usage of `STEitherAmount`. Expect: Occurrences in code that handle the new amount type.
rg --type cpp $'STEitherAmount'

Length of output: 217634


Script:

#!/bin/bash
# Search for remaining uses of STAmount
echo "Remaining uses of STAmount:"
rg --type cpp "STAmount" -c

echo "\nUses of STEitherAmount:"
rg --type cpp "STEitherAmount" -c

echo "\nFiles where both STAmount and STEitherAmount are used:"
rg --type cpp -l "STAmount" | xargs rg --type cpp -l "STEitherAmount" | sort | uniq

echo "\nChecking if all STAmount constructors have been updated:"
rg --type cpp "STAmount\(sit,\s*name\)"

Length of output: 8462


Script:

#!/bin/bash
# Examine STEitherAmount definition
echo "STEitherAmount definition:"
rg --type cpp -A 20 "class STEitherAmount" include/xrpl/protocol/STEitherAmount.h

echo "\nExamples of STAmount and STEitherAmount usage in the same file:"
rg --type cpp -C 5 "STAmount|STEitherAmount" src/libxrpl/protocol/STObject.cpp

echo "\nChecking for comments about STAmount to STEitherAmount transition:"
rg --type cpp -C 3 "STAmount.*STEitherAmount|STEitherAmount.*STAmount"

Length of output: 6923

include/xrpl/protocol/STEitherAmount.h (12)

36-126: LGTM!

The STEitherAmount class is well-designed and implemented. It follows the Single Responsibility Principle by focusing on representing an amount that can be either STAmount or STMPTAmount. The use of std::variant is appropriate for storing the two possible types. The class provides a comprehensive set of constructors, assignment operators, and methods to access and manipulate the stored amount. The get method is a nice touch, allowing type-safe access to the stored amount based on the provided type parameter. The class also properly overrides necessary virtual functions from the base class STBase to provide custom behavior.


128-135: LGTM!

The get function is correctly implemented using std::holds_alternative and std::get to check and retrieve the stored amount of type T. The use of the ValidAmountType concept ensures that the function can only be called with valid amount types (STAmount or STMPTAmount). Throwing a std::logic_error is appropriate when the stored amount does not match the requested type.


137-144: LGTM!

The non-const version of the get function is correctly implemented using std::holds_alternative and std::get to check and retrieve the stored amount of type T. The use of the ValidAmountType concept ensures that the function can only be called with valid amount types (STAmount or STMPTAmount). Throwing a std::logic_error is appropriate when the stored amount does not match the requested type.


146-177: LGTM!

The standalone get function is a well-designed and implemented utility function. It uses if constexpr to handle different input types at compile-time, providing a convenient way to retrieve the stored amount of type T from various input objects. The function correctly handles STEitherAmount, std::optional<STEitherAmount>, and types convertible to STEitherAmount. It also handles both lvalue and rvalue references correctly. The static_assert at the end ensures that the function is only instantiated with valid input types, providing a good compile-time check.


179-180: Skipped reviewing the function implementation.

The amountFromJson function is only declared in this header file, so its implementation cannot be reviewed here. The function signature is correct and follows the naming convention. The purpose of the function is clear from its name and parameter types.


182-183: Skipped reviewing the function implementation.

The amountFromJson function is only declared in this header file, so its implementation cannot be reviewed here. The function signature is correct and follows the naming convention. The purpose of the function is clear from its name and parameter types.


185-186: Skipped reviewing the function implementation.

The amountFromJsonNoThrow function is only declared in this header file, so its implementation cannot be reviewed here. The function signature is correct and follows the naming convention. The purpose of the function is clear from its name and parameter types.


188-189: Skipped reviewing the function implementation.

The amountFromJsonNoThrow function is only declared in this header file, so its implementation cannot be reviewed here. The function signature is correct and follows the naming convention. The purpose of the function is clear from its name and parameter types.


191-203: LGTM!

The operator== function is correctly implemented using std::visit to handle the comparison of the stored amounts. The use of if constexpr allows the function to compare the stored amounts only if they have the same type, avoiding any runtime errors. Returning false when the stored amounts have different types is the correct behavior.


205-209: LGTM!

The operator!= function is correctly implemented by negating the result of operator==. This is a common idiom for implementing operator!= in terms of operator==.


211-219: LGTM!

The isMPT function is correctly implemented using if constexpr to determine the return value based on the type of T. The use of the ValidAmountType concept ensures that the function can only be called with valid amount types (STAmount or STMPTAmount).


221-229: LGTM!

The isMPT function is correctly implemented using if constexpr to handle the different input types. For STEitherAmount, it calls the member isMPT function to determine if the stored amount is an STMPTAmount. For std::optional<STEitherAmount>, it first checks if the optional has a value, and if so, it calls the member isMPT function on the stored `STEitherAmount

include/xrpl/protocol/TxFormats.h (3)

202-203: LGTM!

The addition of the new transaction type ttMPTOKEN_ISSUANCE_CREATE follows the existing pattern and naming convention. The comment provides a clear description of its purpose, and the assigned value is in sequence with the existing transaction types.


205-206: LGTM!

The addition of the new transaction type ttMPTOKEN_ISSUANCE_DESTROY follows the existing pattern and naming convention. The comment provides a clear description of its purpose, and the assigned value is in sequence with the existing transaction types.


211-212: LGTM!

The addition of the new transaction type ttMPTOKEN_ISSUANCE_SET follows the existing pattern and naming convention. The comment provides a clear description of its purpose, and the assigned value is in sequence with the existing transaction types.

include/xrpl/protocol/Serializer.h (2)

347-349: LGTM!

The peek8 function is a useful addition that allows non-destructive reading of the next byte. The implementation looks correct, and the comment clearly indicates the error-throwing behavior.


380-384: Looks good!

The get192 function is a straightforward addition that extends the SerialIter class to handle 192-bit values. The implementation is clean and reuses the existing getBitString template function, which is a good practice.

include/xrpl/basics/Number.h (2)

56-56: LGTM!

The addition of the Number(MPTAmount const& x) constructor enhances the functionality of the Number class by allowing it to handle MPTAmount values. This improves the usability of the class without breaking any existing code.


94-94: LGTM!

The addition of the operator MPTAmount() const conversion operator and the implementation of the Number(MPTAmount const& x) constructor complete the support for MPTAmount in the Number class. This allows seamless conversion between Number and MPTAmount objects, enhancing the interoperability between these types. The constructor implementation correctly initializes the Number object using the value from the MPTAmount object, ensuring consistency with the conversion operator.

Also applies to: 216-219

include/xrpl/protocol/Indexes.h (7)

290-291: LGTM!

The function correctly constructs a Keylet for an MPT issuance using an AccountID and a sequence number.


293-294: LGTM!

The function correctly constructs a Keylet for an MPT issuance using an MPTID.


296-300: LGTM!

The inline function correctly constructs a Keylet for an MPT issuance using a uint256 key.


302-303: LGTM!

The function correctly constructs a Keylet for an MPToken using an MPTID and an AccountID.


305-309: LGTM!

The inline function correctly constructs a Keylet for an MPToken using a uint256 key.


311-312: LGTM!

The function correctly constructs a Keylet for an MPToken using a uint256 issuance key and an AccountID.


354-355: LGTM!

The function declaration for getMptID is correct, taking an AccountID and a sequence number and returning an MPTID.

include/xrpl/protocol/TxFlags.h (5)

25-26: LGTM!

The inclusion of the LedgerFormats.h header file is necessary and follows the correct convention by placing it outside the ripple namespace.


135-143: LGTM!

The constants for MPTokenIssuanceCreate transaction flags are well-defined and follow the naming convention. The comment provides a clear explanation for the intentional omission of the flag value 0x01. The values assigned to the constants are consistent with the related ledger state flags.


145-146: LGTM!

The constant tfMPTUnauthorize for the MPTokenAuthorize transaction flag is well-defined and follows the naming convention. The assigned value is a valid flag value.


148-150: LGTM!

The constants tfMPTLock and tfMPTUnlock for the MPTokenIssuanceSet transaction flags are well-defined and follow the naming convention. The assigned values are valid flag values.


207-218: LGTM!

The constants for flag masks related to MPToken transactions are well-defined and follow a consistent naming convention. The bitwise NOT operations are used correctly to exclude the specified flags and the tfUniversal flag from the valid combinations. The tfMPTokenIssuanceCreateMask constant includes all the relevant tfMPT* flags, while the other mask constants include only the flags specific to their respective transaction types. This ensures that only valid flag combinations can be used for each MPToken transaction type.

include/xrpl/protocol/LedgerFormats.h (4)

199-211: LGTM! The new ledger entry types expand the ledger's capabilities to support MPTokens.

The addition of ltMPTOKEN_ISSUANCE and ltMPTOKEN ledger entry types is a significant enhancement that enables the ledger to handle MPToken assets. ltMPTOKEN_ISSUANCE allows defining MPToken asset types without tracking balances, while ltMPTOKEN enables tracking individual MPToken balances.

The assigned enum values are unique and follow the existing naming convention, and the comments provide clear descriptions of the purpose of each ledger entry type.

This is a non-breaking change that expands the ledger's capabilities.


324-332: LGTM! The new flags enhance the control and management of MPToken issuances.

The addition of flags such as lsfMPTLocked, lsfMPTCanLock, lsfMPTRequireAuth, lsfMPTCanEscrow, lsfMPTCanTrade, lsfMPTCanTransfer, and lsfMPTCanClawback to the LedgerSpecificFlags enum provides granular control over the properties and permissions of MPToken issuances.

These flags allow for fine-grained management of MPTokens within the ledger system, enabling flexibility in setting permissions and properties for each MPToken issuance. The assigned bit values are unique and follow the existing convention.

This enhancement improves the functionality and control over MPToken issuances.


334-335: LGTM! The new flag enhances the management of MPToken balances.

The addition of the lsfMPTAuthorized flag to the LedgerSpecificFlags enum specifically for the ltMPTOKEN ledger entry type provides an additional property for managing MPToken balances.

This flag likely indicates whether an individual MPToken balance is authorized or not, allowing for better control and tracking of the authorization status of MPToken balances within the ledger system.

The assigned bit value is unique and follows the existing convention.


326-326: LGTM! Reusing the lsfMPTLocked flag ensures consistency across MPToken-related ledger entries.

The comment indicates that the lsfMPTLocked flag, originally defined for the ltMPTOKEN_ISSUANCE type, is also used in the ltMPTOKEN type. This reuse of the flag implies that the locked status is applicable to both MPToken issuances and individual MPToken balances.

Reusing the same flag for both types ensures a consistent representation of the locked status across MPToken-related ledger entries, allowing for a unified approach to handling and interpreting the locked status of MPTokens.

This consistency enhances the overall management and understanding of MPToken-related data within the ledger system.

include/xrpl/protocol/Feature.h (2)

83-83: LGTM!

The change to increment numFeatures from 79 to 80 appears to be a valid update to reflect the addition of a new feature.

Please ensure that the actual number of amendments registered in Feature.cpp matches this value to avoid the LogicError on startup, as mentioned in the code comments.


375-375: LGTM!

The addition of the new external variable featureMPTokensV1 to declare a new feature appears to follow the guidelines mentioned in the code comments.

As the next steps, please ensure to:

  1. Add a uint256 definition for featureMPTokensV1 to the corresponding source file (Feature.cpp). Use registerFeature to create the feature with the feature's name, Supported::no, and VoteBehavior::DefaultNo.
  2. Use featureMPTokensV1 as the parameter to view.rules.enabled() to control flow into the new code that this feature limits.
src/libxrpl/protocol/Serializer.cpp (1)

361-368: LGTM!

The peek8() function is a useful addition to the SerialIter class, providing a way to inspect the next byte without consuming it. The implementation is straightforward and includes appropriate error handling.

include/xrpl/protocol/STAmount.h (4)

240-240: Good use of unique_ptr for improved memory safety.

Changing the return type of the construct method from a raw pointer to unique_ptr<STAmount> improves memory safety and ownership semantics. It ensures that the caller of construct takes ownership of the dynamically allocated STAmount object and is responsible for its deletion.

This change aligns with modern C++ best practices of using smart pointers for resource management and helps prevent potential memory leaks.


45-45: Clarify the reason for removing the base classes STBase and CountedObject<STAmount>.

Removing the inheritance from STBase and CountedObject<STAmount> alters the base class structure of STAmount, which could potentially affect the memory management and polymorphic behavior of the class.

Please provide more context on why this change was made and assess the potential impact on the codebase.

To verify the impact of this change, run the following script:

Verification successful

Removal of base classes from STAmount appears to be safe

The verification process has been completed, and no issues were found related to the removal of STBase and CountedObject<STAmount> as base classes for STAmount. Our analysis suggests that:

  1. STAmount is not being used polymorphically in the codebase.
  2. There are no occurrences of STAmount being passed to functions expecting STBase or CountedObject<STAmount>.

Based on this analysis, the change appears to be safe and doesn't seem to have negatively impacted the existing codebase. However, it's still recommended to thoroughly test the changes to ensure no unexpected behavior arises.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `STAmount` is still used polymorphically or if the removal of base classes has affected the codebase.

# Test 1: Search for occurrences where `STAmount` is used as a base class pointer or reference. 
# Expect: No occurrences found.
ast-grep --lang cpp --pattern $'dynamic_cast<STAmount*>($_)'
ast-grep --lang cpp --pattern $'dynamic_cast<STAmount&>($_)'
ast-grep --lang cpp --pattern $'static_cast<STAmount*>($_)'
ast-grep --lang cpp --pattern $'static_cast<STAmount&>($_)'

# Test 2: Search for occurrences where `STAmount` is passed to functions expecting `STBase` or `CountedObject<STAmount>`. 
# Expect: No occurrences found.
rg --type cpp $'STBase \*' -A 5
rg --type cpp $'STBase &' -A 5 
rg --type cpp $'CountedObject<STAmount> \*' -A 5
rg --type cpp $'CountedObject<STAmount> &' -A 5

Length of output: 409


78-78: Clarify the reason for removing the SField parameter from the constructor.

The constructor STAmount(SerialIter& sit, SField const& name) has been simplified to STAmount(SerialIter& sit), removing the SField parameter. This change indicates a shift towards a more streamlined instantiation process.

Please provide more context on how the name parameter was being used previously and why it was removed. Also, clarify how the handling of fields is now being managed after this change.

To verify the impact of this change, run the following script:

Verification successful

To gather more information about the implementation and usage of the STAmount constructor, let's run the following scripts:


Verified: The removal of the SField parameter from the STAmount constructor is consistent.

The change to simplify the STAmount constructor by removing the SField parameter appears to be intentional and consistently implemented. The constructor now focuses solely on processing the serialized data from the SerialIter.

No usage of SField was found within the STAmount class, suggesting that field-related functionality may have been moved elsewhere or is no longer needed.

To improve code documentation:

  • Consider adding a comment in the header file or the implementation file explaining the rationale for removing the SField parameter.
  • If the field handling has been moved elsewhere, it would be helpful to mention where this functionality now resides.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the removal of the `SField` parameter has affected the instantiation of `STAmount` from `SerialIter`.

# Test: Search for occurrences where `STAmount` is being constructed from `SerialIter`. 
# Expect: All occurrences should match the new constructor signature.
rg --type cpp $'STAmount\(SerialIter'

Length of output: 172


Script:

#!/bin/bash
# View the implementation of the STAmount constructor
echo "STAmount constructor implementation:"
rg -A 10 "STAmount::STAmount\(SerialIter& sit\)" src/libxrpl/protocol/STAmount.cpp

# Search for SField usage within the STAmount class
echo -e "\nSField usage within STAmount class:"
ast-grep --lang cpp --pattern 'class STAmount {
  $$$
  $_($_ SField $_) {
    $$$
  }
  $$$
}'

Length of output: 965


217-231: Clarify the reason for removing the override specifiers and the isEquivalent method.

Several methods like getSType, getFullText, getText, getJson, and add have been modified to remove the override specifier, which may indicate a change in the intended inheritance structure or functionality. The removal of override could affect how these methods are resolved at runtime.

Additionally, the isEquivalent method has been removed entirely, which could impact comparisons between STAmount instances.

Please provide more context on why these changes were made and assess the potential impact on the codebase, especially regarding the behavior of STAmount.

To verify the impact of these changes, run the following script:

Verification successful

Removal of override specifiers and isEquivalent method does not significantly impact STAmount usage.

After thorough investigation, we can confirm that the removal of override specifiers and the isEquivalent method from STAmount does not have a significant impact on the codebase:

  1. STAmount is defined as a final class and does not inherit from any base class, so removing override specifiers doesn't affect inheritance or polymorphic behavior.
  2. The isEquivalent method was not part of a polymorphic interface for STAmount.
  3. While comparison operators (== and !=) are not visible in the class definition, they are likely implemented elsewhere and their functionality is maintained.

The changes appear to be a cleanup or refactoring of the STAmount class rather than a functional modification. The behavior of STAmount instances in the codebase should remain consistent with previous versions.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the removal of `override` and `isEquivalent` has affected the behavior of `STAmount`.

# Test 1: Search for occurrences where the modified methods are being called on `STAmount` instances. 
# Expect: Verify that the method calls are still valid and the expected behavior is maintained.
rg --type cpp $'STAmount::getSType\(' 
rg --type cpp $'STAmount::getFullText\('
rg --type cpp $'STAmount::getText\('
rg --type cpp $'STAmount::getJson\('
rg --type cpp $'STAmount::add\('

# Test 2: Search for occurrences where `isEquivalent` is being called on `STAmount` instances.
# Expect: No occurrences found. If found, verify that the comparisons are still valid after the removal of `isEquivalent`.
rg --type cpp $'STAmount::isEquivalent\('

Length of output: 570


Script:

#!/bin/bash
# Description: Further verify the impact of removing `override` specifiers and `isEquivalent` method

# Check for usage of methods on STAmount instances or through base class pointers/references
rg --type cpp -e '\.getSType\(\)' -e '\.getFullText\(\)' -e '\.getText\(\)' -e '\.getJson\(' -e '\.add\('

# Find the base class of STAmount
rg --type cpp 'class\s+STAmount\s*:\s*public'

# Search for comparisons or equivalence checks on STAmount objects
rg --type cpp -e 'STAmount.*==.*STAmount' -e 'STAmount.*!=.*STAmount' -e 'STAmount.*compare.*STAmount'

# Check if isEquivalent is defined in a base class
rg --type cpp 'virtual.*isEquivalent'

Length of output: 54533


Script:

#!/bin/bash
# Description: Further verify the impact of removing `override` specifiers and `isEquivalent` method from STAmount

# Check if STAmount is part of any inheritance hierarchy
rg --type cpp 'class\s+\w+\s*:\s*public\s+STAmount'
rg --type cpp 'class\s+STAmount\s*:\s*public\s+\w+'

# Check for any indirect uses of isEquivalent
rg --type cpp 'isEquivalent'

# Verify implementation of comparison operators for STAmount
rg --type cpp 'STAmount::operator=='
rg --type cpp 'STAmount::operator!='

Length of output: 4118


Script:

#!/bin/bash
# Description: Final verification of STAmount implementation and usage

# Check for non-member operator implementations for STAmount
rg --type cpp 'operator==\s*\(\s*const\s+STAmount\s*&'
rg --type cpp 'operator!=\s*\(\s*const\s+STAmount\s*&'

# Look for potential base classes of STAmount
rg --type cpp 'class\s+STAmount\s*:' -A 5

# Check for polymorphic usage of STAmount
rg --type cpp 'virtual.*STAmount'
rg --type cpp 'std::unique_ptr<\s*STAmount>'
rg --type cpp 'std::shared_ptr<\s*STAmount>'

# Search for inline comparison operators in STAmount definition
rg --type cpp 'class\s+STAmount' -A 50

Length of output: 16013

src/libxrpl/protocol/STEitherAmount.cpp (5)

30-39: LGTM!

The constructor correctly deserializes an STEitherAmount from a SerialIter by checking the first byte to determine the type of amount and constructing the appropriate type.


41-82: LGTM!

The constructors and assignment operators for STEitherAmount provide flexibility and convenience in creating and assigning values from different types of amounts (XRPAmount, STAmount, or STMPTAmount). The code is straightforward and does not contain any apparent issues.


84-210: LGTM!

The methods defined for STEitherAmount provide a consistent and well-structured interface for accessing and manipulating the amount, regardless of the underlying type (STAmount or STMPTAmount). The use of std::visit allows for clean and concise code, and the methods handle the differences between STAmount and STMPTAmount appropriately. The code follows a consistent pattern and does not contain any apparent issues.


212-423: LGTM!

The utility functions for creating STEitherAmount instances from JSON representations are well-structured and handle different JSON value types appropriately. The amountFromJson function correctly extracts the necessary information from the JSON value to create an STEitherAmount and performs necessary validations, throwing exceptions for invalid JSON representations or out-of-range values. The amountFromJsonNoThrow functions provide a convenient way to create an STEitherAmount or STAmount from JSON without explicit exception handling. The code is well-organized and does not contain any apparent issues.


425-425: LGTM!

The closing namespace brace for the ripple namespace is necessary and correctly placed.

src/libxrpl/protocol/Indexes.cpp (5)

76-77: LGTM!

The addition of the new MPTOKEN_ISSUANCE and MPTOKEN enumerations to the LedgerNameSpace enum is a clear indication of the introduction of MPToken functionality. The assigned character values are consistent with the existing enumerations, and the changes are well-documented.


140-148: LGTM!

The getMptID function is a well-implemented utility for generating unique MPTIDs based on an account ID and a sequence number. The use of big-endian conversion for the sequence number ensures consistent ordering, and the concatenation with the account ID guarantees uniqueness.


466-470: LGTM!

The mptIssuance function provides a convenient way to create a keylet for MPTOKEN issuance using an account ID and a sequence number. By leveraging the getMptID function and delegating to another overload, it maintains a clean and readable implementation. The noexcept specifier is also a good practice.


472-477: LGTM!

This overload of the mptIssuance function provides a straightforward way to create a keylet for MPTOKEN issuance directly from an MPTID. The use of the indexHash function with the appropriate namespace ensures that the generated keylet key is unique and consistent. The noexcept specifier is also a good practice.


479-490: LGTM!

The two new overloads of the mptoken function provide flexible ways to create keylets for MPTokens. The first overload allows creating a keylet using an MPTID and a holder's AccountID, while the second overload directly uses the issuance key and the holder's AccountID. The use of the indexHash function with the appropriate namespace ensures that the generated keylet keys are unique and consistent. The noexcept specifiers are also a good practice.

include/xrpl/protocol/XChainAttestations.h (2)

146-146: Approve the change from STAmount to STEitherAmount for sendingAmount.

The modification to use STEitherAmount instead of STAmount for the sendingAmount parameter is a good change. It suggests that the function now supports a more flexible representation of amounts, potentially allowing for handling different types of amounts, such as native and issued currencies.

This change enhances the functionality of the message function in AttestationClaim to work with a broader range of amount types, making it more versatile.


229-230: Approve the changes from STAmount to STEitherAmount for sendingAmount and rewardAmount.

The modifications to use STEitherAmount instead of STAmount for both the sendingAmount and rewardAmount parameters in the message function of AttestationCreateAccount are consistent with the changes made in AttestationClaim.

These changes suggest a broader shift towards supporting more flexible amount representations across the attestation-related functions. By utilizing STEitherAmount, the function can now handle a wider range of amount types, such as native and issued currencies, enhancing its versatility and applicability in different scenarios.

The consistency in adopting STEitherAmount across the attestation functions improves the overall coherence and extensibility of the codebase.

src/libxrpl/protocol/LedgerFormats.cpp (2)

368-383: LGTM!

The addition of the MPTokenIssuance ledger entry type follows the existing pattern and includes the necessary fields for managing MP token issuances. The required and optional fields are appropriately marked, and the use of soeDEFAULT for default values is consistent with other entry types.


385-396: LGTM!

The addition of the MPToken ledger entry type follows the existing pattern and includes the necessary fields for tracking and managing MP tokens owned by accounts. The required and optional fields are appropriately marked, and the use of soeDEFAULT for default values is consistent with other entry types.

src/libxrpl/protocol/TxFormats.cpp (5)

165-165: LGTM!

The change to associate the sfAmount field in the ttPAYMENT transaction type with multi-party transaction support is consistent with the provided summary and appears to be correct.

[consistent_summary]


380-380: LGTM!

The change to associate the sfAmount field in the ttCLAWBACK transaction type with multi-party transaction support is consistent with the provided summary and appears to be correct.

[consistent_summary]


381-381: LGTM!

The addition of the optional sfMPTokenHolder field to the ttCLAWBACK transaction type is consistent with the provided summary and appears to be correct. This change enhances the functionality of the clawback process by allowing the specification of the token holder.

[consistent_summary]


518-526: LGTM!

The addition of the MPTokenIssuanceCreate transaction type with optional fields sfAssetScale, sfTransferFee, sfMaximumAmount, and sfMPTokenMetadata is consistent with the provided summary and appears to be correct. This change enhances the protocol's capabilities for multi-party token management and provides flexibility in the token issuance process.

[consistent_summary]


528-533: LGTM!

The addition of the MPTokenIssuanceDestroy, MPTokenAuthorize, and MPTokenIssuanceSet transaction types with their respective required and optional fields is consistent with the provided summary and appears to be correct. These changes further expand the protocol's capabilities for managing multi-party tokens, allowing for the destruction, authorization, and setting of token issuances and holders.

[consistent_summary]

Also applies to: 535-541, 543-549

include/xrpl/basics/base_uint.h (2)

551-551: LGTM!

The new uint192 type alias is a useful addition to the base_uint class, providing support for 192-bit unsigned integers. The change is consistent with the existing type aliases and expands the available options.


637-637: Looks good!

The static assertion for uint192 is a helpful addition to ensure that the type has the expected size of 24 bytes without any padding. It maintains consistency with the existing static assertions for other bit-width types and helps catch any potential issues at compile-time.

src/libxrpl/protocol/STTx.cpp (2)

547-570: LGTM!

The new invalidMPTAmountInTx function correctly checks for unsupported MPT amounts in transactions based on the transaction type. This is a valuable addition to the validation logic.


590-594: LGTM!

The modification to passesLocalChecks correctly incorporates the new invalidMPTAmountInTx check, preventing transactions with unsupported MPT amounts from passing local checks.

src/libxrpl/basics/Number.cpp (1)

507-510: LGTM!

The addition of the operator MPTAmount() conversion operator to the Number class is a logical enhancement that enables seamless conversion from Number instances to MPTAmount. This change aligns with the broader goal of introducing multi-party token (MPT) functionality to the codebase.

The implementation utilizes a static cast of the internal representation (rep) of the Number instance, which is consistent with the existing operator XRPAmount() conversion operator.

This addition will facilitate operations and interactions involving MPTAmount within the codebase, promoting consistency and interoperability between different amount representations.

include/xrpl/protocol/TER.h (2)

128-128: Approve adding the new temBAD_MPTOKEN_TRANSFER_FEE error code.

The new temBAD_MPTOKEN_TRANSFER_FEE error code in the TEMcodes enum is a valuable addition for handling malformed fee scenarios specific to multi-party token transfers. This allows for more precise error reporting and suggests an expansion of the protocol's capabilities in managing multi-party token use cases.


344-348: Approve adding the new tecMPTOKEN_* and tecMPT_* error codes.

The addition of the new tecMPTOKEN_EXISTS, tecMPT_MAX_AMOUNT_EXCEEDED, tecMPT_LOCKED, tecMPT_NOT_SUPPORTED, and tecMPT_ISSUANCE_NOT_FOUND error codes to the TECcodes enum is a significant enhancement for handling multi-party token transactions.

These granular tec-class codes enable precise error reporting for various failure scenarios specific to multi-party tokens, such as pre-existing tokens, exceeded limits, locked tokens, unsupported operations, and missing issuances.

The expanded error code range demonstrates a substantial improvement in the protocol's capabilities to support and manage multi-party token use cases with well-defined error conditions. This enhances the overall robustness and clarity in communicating transaction failures to clients.

src/libxrpl/protocol/TER.cpp (4)

88-88: LGTM!

The new error code tecMPT_NOT_SUPPORTED is added correctly to handle scenarios where MPT functionality is not supported.


119-120: LGTM!

The new error codes tecMPTOKEN_EXISTS and tecMPT_MAX_AMOUNT_EXCEEDED are added correctly to handle specific scenarios related to MPToken functionality.


121-122: LGTM!

The new error codes tecMPT_LOCKED and tecMPT_ISSUANCE_NOT_FOUND are added correctly to handle specific scenarios related to MPToken functionality.


205-205: LGTM!

The new error code temBAD_MPTOKEN_TRANSFER_FEE is added correctly to handle scenarios where the provided MPToken transfer fee is malformed and outside the valid range of 1 to 5000, inclusive.

src/libxrpl/protocol/STObject.cpp (4)

607-611: LGTM!

The new getFieldH192 function looks good. It correctly retrieves a 192-bit hash value from the object using the getFieldByValue template and returns it as a uint192.


636-637: Good use of a static empty object for missing fields.

Returning a const reference to a static empty STEitherAmount when the field is not found is a good way to handle missing fields. It avoids null reference issues while minimizing object allocations.


640-645: LGTM!

The new getFieldAmount overload looks good. It allows retrieving an STAmount from an STEitherAmount field using the TypedVariantField. This maintains backward compatibility for code that expects an STAmount.


759-761: Verify all callers have been updated to pass an STEitherAmount.

The function signature has been changed to take an STEitherAmount parameter instead of STAmount. This is a breaking change.

Run the following script to find all callers of setFieldAmount and ensure they have been updated to pass an STEitherAmount:

Verification successful

To further verify the compatibility between STAmount and STEitherAmount, we need to examine the definition and implementation of STEitherAmount. Let's search for its definition in the codebase.


Existing calls to setFieldAmount using STAmount are compatible with the new signature.

The change to setFieldAmount to accept STEitherAmount is backward compatible. STEitherAmount has an implicit constructor that takes STAmount, allowing existing code to work without modifications. This design ensures that calls passing STAmount or XRPAmount remain valid.

  • No changes are required for existing setFieldAmount calls in the codebase.
  • The new STEitherAmount type adds flexibility while maintaining compatibility with STAmount.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash 
# Description: Find all callers of setFieldAmount and check if they pass an STEitherAmount.

# Test: Search for calls to setFieldAmount. Expect: Only calls that pass an STEitherAmount.
rg --type cpp $'setFieldAmount\(' -A 5

Length of output: 20505


Script:

#!/bin/bash
# Search for the definition of STEitherAmount
rg --type cpp "class STEitherAmount" -A 10

Length of output: 1372

src/libxrpl/protocol/Feature.cpp (1)

504-504: LGTM!

The registration of the MPTokensV1 feature looks good. It enables the potential activation of multi-party tokens functionality in the XRPL protocol while ensuring it requires explicit validator approval.

src/libxrpl/protocol/XChainAttestations.cpp (10)

110-110: LGTM!

Extracting STAmount from STEitherAmount using get<STAmount> ensures the correct type is used for initializing sendingAmount. This change aligns with the broader transition to STEitherAmount for amount handling.


135-135: Looks good!

Wrapping sendingAmount in STEitherAmount when adding it to the STObject ensures consistency with the new approach of using STEitherAmount for amount serialization. This change aligns with the broader transition to STEitherAmount for amount handling.


469-469: LGTM!

Extracting STAmount from STEitherAmount using get<STAmount> ensures the correct type is used for initializing amount. This change aligns with the broader transition to STEitherAmount for amount handling.


506-506: Looks good!

Wrapping amount in STEitherAmount when adding it to the STObject ensures consistency with the new approach of using STEitherAmount for amount serialization. This change aligns with the broader transition to STEitherAmount for amount handling.


566-566: Skipping redundant change.

Changing the parameter type from STAmount to STAmount for amount_ does not introduce any functional changes. This change can be skipped.


579-579: LGTM!

Extracting STAmount from STEitherAmount using get<STAmount> ensures the correct type is used for initializing amount. This change aligns with the broader transition to STEitherAmount for amount handling.


619-619: Looks good!

Wrapping amount in STEitherAmount with an explicit sfAmount field when adding it to the STObject ensures consistency with the new approach of using STEitherAmount for amount serialization. Specifying the field explicitly provides clarity about the type of amount being serialized. This change aligns with the broader transition to STEitherAmount for amount handling.


567-567: Skipping redundant change.

Changing the parameter type from STAmount to STAmount for rewardAmount_ does not introduce any functional changes. This change can be skipped.


219-219: Verify the method signature change in the codebase.

Updating the sendingAmount parameter type from STAmount to STEitherAmount allows the method to handle different types of amounts, enhancing flexibility. This change aligns with the broader transition to STEitherAmount for amount handling.

Run the following script to verify the method usage:

Verification successful

Method signature change verified and consistently applied

The AttestationClaim::message method signature change from STAmount to STEitherAmount has been successfully verified across the codebase. All occurrences of the method, including its definition, overload, and usage in tests, consistently use the new STEitherAmount parameter type for sendingAmount.

  • src/libxrpl/protocol/XChainAttestations.cpp: Method definition and overload updated
  • src/test/jtx/impl/attester.cpp: Test usage updated
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `AttestationClaim::message` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type cpp -A 5 $'AttestationClaim::message'

Length of output: 1456


364-365: Verify the method signature and implementation changes in the codebase.

Updating the sendingAmount and rewardAmount parameter types from STAmount to STEitherAmount allows the method to handle different types of amounts, enhancing flexibility. This change aligns with the broader transition to STEitherAmount for amount handling.

The implementation change of wrapping sendingAmount in STEitherAmount when adding it to the STObject ensures consistency with the new serialization approach.

Run the following script to verify the method usage and implementation:

Also applies to: 374-374

Verification successful

To complete our verification, we need to check the types of sendingAmount and rewardAmount in the test file. Let's run an additional script to inspect the relevant part of the test file.


Verification successful: Method signature and implementation changes are consistent across the codebase.

The changes to the AttestationCreateAccount::message method signature, updating sendingAmount and rewardAmount from STAmount to STEitherAmount, have been correctly implemented and are consistent throughout the codebase. This includes:

  • The method definition in src/libxrpl/protocol/XChainAttestations.cpp
  • The method usage within the same file
  • The test implementation in src/test/jtx/impl/attester.cpp

The transition to STEitherAmount for amount handling has been applied consistently, enhancing flexibility while maintaining proper type usage across different parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `AttestationCreateAccount::message` match the new signature and implementation.

# Test: Search for the method usage. Expect: Only occurrences of the new signature and implementation.
rg --type cpp -A 10 $'AttestationCreateAccount::message'

Length of output: 2386


Script:

#!/bin/bash
# Description: Inspect the types of sendingAmount and rewardAmount in the test file

# Search for the relevant part of the test file
rg --type cpp -A 20 -B 10 'AttestationCreateAccount::message' src/test/jtx/impl/attester.cpp

Length of output: 750

include/xrpl/protocol/SField.h (5)

45-45: LGTM!

The forward declaration of STEitherAmount is a valid addition to support the new multi-party token (MPT) functionality.


60-101: LGTM!

The XMACRO update to include STI_EITHER_AMOUNT with the same serialization ID as STI_AMOUNT is a clever way to maintain backward compatibility while introducing the new STEitherAmount type. The comments provide clear reasoning for this design choice.


332-376: LGTM!

The introduction of TypedVariantField and OptionaledVariantField provides a type-safe and expressive way to handle variant fields in the XRPL protocol. The template parameters allow specifying the variant type and its alternative type at compile time, enabling direct access to the desired type through STObject::operator[]().

The code is well-structured, properly templated, and includes clear documentation with examples demonstrating its usage. The operator~ overload for creating an OptionaledVariantField is a nice touch for concise syntax.

Overall, this is a solid addition to the codebase.


394-395: LGTM!

The updates to the SF_AMOUNT and SF_EITHER_AMOUNT type aliases are consistent with the introduction of TypedVariantField and STEitherAmount.

SF_AMOUNT now allows fields to represent either an STAmount or an STEitherAmount, which is useful for fields that don't support MPT. On the other hand, SF_EITHER_AMOUNT represents fields that can hold any type of STEitherAmount.

These type aliases provide a clear distinction between MPT-supported fields and those limited to STAmount. The changes are well-aligned with the overall MPT implementation.


517-520: New SF_UINT64 fields for MPT functionality.

The new extern variables sfMaximumAmount, sfOutstandingAmount, sfLockedAmount, and sfMPTAmount seem to be related to the MPT functionality. Their names suggest they represent various amounts associated with MPTs.

The naming follows the existing sfXXX convention, which is good for consistency. However, without more context about their specific usage and purpose, it's hard to determine if the names are fully appropriate.

Could you please provide more information about the intended purpose and semantics of these new fields? This will help ensure that their names accurately reflect their usage within the MPT system.

src/libxrpl/protocol/SField.cpp (7)

48-55: LGTM!

The new constructor for TypedVariantField looks good. It provides a way to construct objects using a private access tag and variadic arguments, ensuring that only authorized code can create instances of this class. Forwarding the arguments to the base class constructor is a clean way to handle the initialization.


110-110: New SField looks good!

The new SField sfAssetScale is well-defined with a type of UINT8 and a unique field value of 20. The naming and type choice seem appropriate for representing an asset scale value.


206-209: New amount-related SFields look good!

The new SFields sfMaximumAmount, sfOutstandingAmount, sfLockedAmount, and sfMPTAmount are well-defined with a type of UINT64 and unique, sequential field values. The naming and type choice seem appropriate for representing various amount-related values.


221-221: New SField for multi-party token issuance ID looks good!

The new SField sfMPTokenIssuanceID is well-defined with a type of UINT192 and a unique field value of 1. The naming and type choice seem appropriate for representing a multi-party token issuance ID.


327-327: New SField for multi-party token metadata looks good!

The new SField sfMPTokenMetadata is well-defined with a type of VL and a unique field value of 30. The naming and type choice seem appropriate for representing metadata associated with a multi-party token.


340-340: New SField for multi-party token holder account looks good!

The new SField sfMPTokenHolder is well-defined with a type of ACCOUNT and a unique field value of 11. The naming and type choice seem appropriate for representing the account of a multi-party token holder.


260-260: Type change for sfAmount looks good, but verify the impact.

The type change from AMOUNT to EITHER_AMOUNT for the SField sfAmount seems reasonable, as it allows for more flexibility in representing amount values.

However, this change could have implications on how the amount is serialized and deserialized. It's important to verify the impact of this change on the existing codebase and make any necessary updates to handle the new EITHER_AMOUNT type correctly.

Run the following script to find all occurrences of sfAmount in the codebase and review how it's being used:

Verification successful

sfAmount type change to EITHER_AMOUNT is correctly implemented and supported.

The modification of sfAmount from AMOUNT to EITHER_AMOUNT has been successfully implemented across the codebase. This change allows for greater flexibility in representing amount values, supporting both traditional AMOUNT and Multi-Purpose Token (MPT) types. Key observations:

  1. Transaction formats have been updated to use sfAmount with the soeMPTSupported flag where appropriate.
  2. Ledger formats and inner object formats continue to use sfAmount consistently.
  3. Many parts of the code already handle sfAmount as an STEitherAmount type, indicating proper implementation throughout the codebase.
  4. No obvious errors or incompatibilities were introduced by this change.

The codebase appears to have been thoroughly updated to support this modification, and the change is well-integrated across various components.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of `sfAmount` in the codebase.

# Test: Search for `sfAmount` usage. Expect: Locations where `sfAmount` is used.
rg --type cpp -A 5 $'sfAmount'

Length of output: 77676

src/libxrpl/protocol/STParsedJSON.cpp (2)

457-479: LGTM!

The new case block for handling STI_UINT192 looks good. It follows the same pattern as the existing code for parsing other unsigned integer types from JSON strings. The error handling is consistent, and it correctly handles both valid hex strings and empty strings.


559-560: Verify the impact of the return type change on the codebase.

The return type of the STI_AMOUNT case has been changed from STAmount to STEitherAmount. This change suggests that STEitherAmount is a new type that provides a more flexible representation of amounts. However, it's important to verify that all the code consuming the parsed amount value is updated to handle the new return type correctly.

Run the following script to find all occurrences of amountFromJson and ensure that the return value is handled correctly:

Verification successful

The change to STEitherAmount is part of a broader refactoring and appears to be properly handled.

After analyzing the codebase, it's evident that the change from STAmount to STEitherAmount is part of a larger refactoring effort to support both types. The amountFromJson and amountFromJsonNoThrow functions have been updated with overloads to handle both STAmount and STEitherAmount. Most of the application code uses amountFromJsonNoThrow, which has been adapted to work with the new STEitherAmount type.

The change in STParsedJSON.cpp is consistent with these updates, and the rest of the codebase appears to have been modified to accommodate the new STEitherAmount type. This suggests that the impact of the change has been carefully considered and implemented across the project.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all occurrences of `amountFromJson` handle the new return type.

# Test: Search for `amountFromJson` function calls. Expect: Only occurrences handling `STEitherAmount`.
rg --type cpp -A 5 $'amountFromJson'

Length of output: 13335

include/xrpl/protocol/STObject.h (12)

29-29: Provide more context about the Rules.h header.

Please explain the purpose of including the Rules.h header and how it impacts the STObject class. It would be helpful to understand the dependencies introduced by this change.


33-33: Provide more context about the STEitherAmount type.

Please explain what the STEitherAmount type represents and how it is used within the STObject class. Some examples of its usage would be helpful to understand the impact of this change.


58-60: LGTM! The additional template parameter enhances flexibility.

The introduction of the H template parameter with a default value of T allows the Proxy class to handle a different type than T when needed, while still maintaining the existing behavior by default. This change enhances the flexibility of the Proxy class without affecting existing code.


62-63: LGTM! The additional template parameter enhances flexibility.

The introduction of the H template parameter with a default value of T allows the OptionalProxy class to handle a different type than T when needed, while still maintaining the existing behavior by default. This change enhances the flexibility of the OptionalProxy class without affecting existing code.


230-231: LGTM! The new function adds support for 192-bit hash fields.

The addition of the getFieldH192 function allows the STObject class to retrieve 192-bit hash values from fields, which is consistent with the existing support for other hash sizes. This change enhances the functionality of the class without introducing any apparent issues.


239-243: LGTM! The changes support the new STEitherAmount type.

The modification of the getFieldAmount function to return a STEitherAmount reference aligns with the introduction of the STEitherAmount type for representing amounts in the STObject class. The new overload of getFieldAmount that takes a TypedVariantField<STEitherAmount, STAmount> parameter provides a way to retrieve a STAmount reference from fields that can be either STEitherAmount or STAmount, enhancing the flexibility of the class.


264-268: LGTM! The new overload enhances convenience.

The introduction of the new operator[] overload that takes a TypedVariantField<T, H> parameter allows accessing variant fields in a more convenient way. It eliminates the need to explicitly specify the underlying type when retrieving the value of a variant field, improving the usability of the STObject class.


282-286: LGTM! The new overload enhances convenience.

The introduction of the new operator[] overload that takes an OptionaledVariantField<T, H> parameter allows accessing optional variant fields in a more convenient way. It returns an optional<H::value_type>, handling the case when the field is not present. This improves the usability of the STObject class when working with optional variant fields.


299-303: LGTM! The new overload provides modifiable access to variant fields.

The introduction of the new operator[] overload that takes a TypedVariantField<T, H> parameter and returns a ValueProxy<T, H> allows accessing variant fields in a modifiable way. It provides a convenient way to retrieve a modifiable reference to the value of a variant field through the ValueProxy class, enhancing the flexibility of the STObject class.


318-322: LGTM! The new overload provides modifiable access to optional variant fields.

The introduction of the new operator[] overload that takes an OptionaledVariantField<T, H> parameter and returns an OptionalProxy<T, H> allows accessing optional variant fields in a modifiable way. It provides a convenient way to retrieve a modifiable reference to the value of an optional variant field through the OptionalProxy class, handling the case when the field is not present. This enhances the flexibility of the STObject class when working with optional variant fields.


335-339: LGTM! The new overload provides safe access to variant fields.

The introduction of the new at overload that takes a TypedVariantField<T, H> parameter and returns a H::value_type allows accessing variant fields in a safe way. It retrieves the value of a variant field, throwing an exception if the field is not present. This ensures that the code explicitly handles the case when a required field is missing, improving the reliability of the STObject class.


353-357: LGTM! The new overload provides safe access to optional variant fields.

The introduction of the new at overload that takes an OptionaledVariantField<T, H> parameter and returns an optional<H::value_type> allows accessing optional variant fields in a safe way. It retrieves the value of an optional variant field as an optional, returning nullopt if the field is not present. This provides a clear and explicit way to handle the presence or absence of an optional field, improving the reliability and readability of the code.

src/libxrpl/protocol/STAmount.cpp (6)

88-88: LGTM!

The removal of the SField const& name parameter simplifies the constructor and aligns with the other constructors. The deserialization logic remains intact.


181-181: LGTM!

The new private constructor allows creating an STAmount object without canonicalization, which can be useful for internal use cases where the input has already been validated. The unchecked tag clearly indicates the responsibility of the caller to ensure the validity of the input.


259-261: LGTM!

The modification of the construct method to remove the SField const& name parameter aligns with the changes made to the constructor. The method now creates an STAmount object using the simplified constructor.


344-353: LGTM!

The modifications to the addition operator simplify the handling of the native currency case. By using getSNValue to retrieve the signed integer values and constructing the result using the modified constructor, the code becomes more concise and aligned with the recent changes.


1011-1011: LGTM!

The modifications to the multiplication operator simplify the handling of the native currency case. By performing the multiplication directly and constructing the result using the modified constructor, the code becomes more concise and aligned with the recent changes. The overflow checks ensure the safety of the operation.


1397-1402: LGTM!

The new operator overload for streaming STAmount objects to output streams is a useful addition. It provides a convenient way to output the full text representation of STAmount objects using the getFullText method. The implementation is straightforward and follows the expected behavior for stream output operators.

include/xrpl/protocol/jss.h (6)

44-45: LGTM!

The new JSON fields AL_size and AL_hit_rate follow the existing naming convention and have clear comments indicating their usage in the GetCounts output.


50-57: Looks good!

The new AMM-related JSON fields are named consistently, follow existing conventions, and have clear comments indicating their types (transaction or ledger).


60-67: Approved.

The new AMM-related JSON fields have clear naming, follow existing conventions, and include comments specifying their usage as input or output parameters.


99-105: Looks good to me!

The new JSON fields related to multi-party tokens (MPT) are clearly named with the "MPToken" prefix and have comments indicating their types (ledger or transaction). The addition of these fields supports the introduction of MPT functionality in the protocol.


246-250: Approved.

The new JSON fields related to MPT functionality have clear naming that associates them with MPTs and follows existing conventions. The comments specify their usage as input or output parameters, providing additional context.


378-379: LGTM!

The new JSON field holders is clearly named, follows existing conventions, and has a comment indicating its usage in the MPTHolders output, which is related to MPT functionality.

Comment on lines +63 to +67
inline bool
isXRP(MPTID const&)
{
return false;
}
Copy link

@coderabbitai coderabbitai bot Sep 15, 2024

Choose a reason for hiding this comment

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

Add a TODO comment to indicate that the function needs proper implementation.

The isXRP function is currently hardcoded to always return false, regardless of the input MPTID. This seems to be a placeholder implementation and does not utilize the input parameter.

Consider adding a TODO comment to indicate that the function needs to be properly implemented in the future:

 inline bool
 isXRP(MPTID const&)
 {
+    // TODO: Implement proper logic to determine if the MPTID represents XRP
     return 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
inline bool
isXRP(MPTID const&)
{
return false;
}
inline bool
isXRP(MPTID const&)
{
// TODO: Implement proper logic to determine if the MPTID represents XRP
return false;
}

Choose a reason for hiding this comment

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

This is a valid overload. MPT is never XRP.

Copy link

Choose a reason for hiding this comment

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

@gregtatcam, thank you for the clarification. Understood that MPT is never XRP, so the function correctly returns false.

🐰🤔


Learnings added
Learnt from: gregtatcam
PR: bachase/rippled#4
File: include/xrpl/protocol/MPTIssue.h:63-67
Timestamp: 2024-09-16T13:21:53.595Z
Learning: MPT is never XRP, so the function `isXRP(MPTID const&)` should always return `false`.

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 on lines +181 to +185
inline bool
isLegalNet(STMPTAmount const& value)
{
return true;
}
Copy link

@coderabbitai coderabbitai bot Sep 15, 2024

Choose a reason for hiding this comment

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

Consider adding validation in the isLegalNet function.

The isLegalNet function currently always returns true, indicating that all STMPTAmount values are considered legal in the network. However, it may be beneficial to add some validation logic to ensure that the STMPTAmount values meet certain criteria before considering them legal.

For example, you could check if the amount falls within a valid range, if the issue (currency) is supported, or if there are any other network-specific rules that need to be satisfied.

By adding appropriate validation, you can enhance the security and integrity of the network by preventing the use of invalid or malicious STMPTAmount values.

Choose a reason for hiding this comment

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

Similar to isXRP above. isLegalNet checks for valid XRP. It's always true for MPT.

Copy link

Choose a reason for hiding this comment

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

@gregtatcam, thank you for the clarification. I understand that isLegalNet is intended to always return true for MPT amounts, similar to isXRP. I appreciate the explanation.

(^・ω・^)Thinking bunny appreciates the new insight!


Learnings added
Learnt from: gregtatcam
PR: bachase/rippled#4
File: include/xrpl/protocol/STMPTAmount.h:181-185
Timestamp: 2024-09-16T13:23:22.234Z
Learning: In the context of `STMPTAmount`, the `isLegalNet` function is intended to always return `true`, mirroring the behavior of `isXRP` for XRP amounts.

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 on lines +208 to +209
/** This transaction destroys an existing MPTokenIssuance object. */
ttMPTOKEN_AUTHORIZE = 56,
Copy link

@coderabbitai coderabbitai bot Sep 15, 2024

Choose a reason for hiding this comment

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

Inconsistency between the transaction type name and the comment.

The transaction type is named ttMPTOKEN_AUTHORIZE, which suggests that it is used to authorize an MPTokenIssuance object. However, the comment mentions destroying an existing MPTokenIssuance object, which seems inconsistent with the name.

Please update the comment to accurately reflect the purpose of the ttMPTOKEN_AUTHORIZE transaction type.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@gregtatcam @shawnxie999 -- this one was an actual catch!

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines +633 to +638
STEitherAmount const&
STObject::getFieldAmount(SField const& field) const
{
static STAmount const empty{};
return getFieldByConstRef<STAmount>(field, empty);
static STEitherAmount const empty{};
return getFieldByConstRef<STEitherAmount>(field, empty);
}
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Based on the analysis of the search results, I can provide a final response regarding the change in the return type of getFieldAmount from STAmount to STEitherAmount.

Potential compatibility issues detected with STAmount-specific method calls.

While there are no explicit casts to STAmount or direct comparisons with STAmount, the search results reveal usage of STAmount-specific methods (.native(), .issue(), and .getIssuer()) on the return value of getFieldAmount. This suggests that the existing code assumes an STAmount return type, which may lead to compatibility issues with the new STEitherAmount return type.

Affected files and operations:

  • src/xrpld/app/tx/detail/CreateOffer.cpp: .native()
  • src/test/jtx/PathSet.h: .issue()
  • src/xrpld/app/tx/detail/InvariantCheck.cpp: .issue()
  • src/xrpld/app/ledger/OrderBookDB.cpp: .issue()
  • src/xrpld/rpc/detail/RPCHelpers.cpp: .getIssuer()
  • src/xrpld/rpc/handlers/NoRippleCheck.cpp: .getIssuer()
  • src/xrpld/rpc/handlers/AccountLines.cpp: .getIssuer()
  • src/xrpld/ledger/detail/View.cpp: .getIssuer()

To ensure compatibility:

  1. Review the affected files and update the code to handle both STAmount and STEitherAmount return types.
  2. Consider introducing a compatibility layer or helper functions to safely handle the new return type while maintaining backward compatibility.
  3. Update unit tests to cover both STAmount and STEitherAmount scenarios.
Analysis chain

Verify all callers have been updated to handle the new return type.

The function signature has been changed to return a const reference to STEitherAmount instead of STAmount. This is a breaking change.

Run the following script to find all callers of getFieldAmount and ensure they have been updated to handle the new return type:


To ensure that the change from STAmount to STEitherAmount in the return type of getFieldAmount is not causing any issues, we need to search for any explicit casts or type-specific operations being performed on the return value. Let's run another search to check for such cases.

This script will search for any usage of getFieldAmount followed by member access (.), pointer dereference (->), as keyword, static_cast, or explicit cast to STAmount. These patterns would indicate type-specific operations that might be affected by the change in return type.


Let's try a series of simpler searches to look for potential type-specific usage of getFieldAmount results. We'll split our search into multiple commands, each focusing on a specific pattern.

These searches will help us identify if there are any type-specific operations being performed on the results of getFieldAmount that might be affected by the change from STAmount to STEitherAmount.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all callers of getFieldAmount and check if they handle STEitherAmount.

# Test: Search for calls to getFieldAmount. Expect: Only calls that handle STEitherAmount.
rg --type cpp $'getFieldAmount\(' -A 5 

Length of output: 47820


Script:

#!/bin/bash
# Search for explicit casts or type-specific operations on getFieldAmount results
rg --type cpp 'getFieldAmount\([^)]+\)\s*(?:\.\w+|\-\>|as\s+\w+|static_cast|\(STAmount\))' -A 3

Length of output: 275


Script:

#!/bin/bash
# Search for type-specific operations on getFieldAmount results

echo "Searching for .native() calls on getFieldAmount results:"
rg --type cpp 'getFieldAmount\([^)]+\)\.native\(\)' -A 2

echo "\nSearching for .issue() calls on getFieldAmount results:"
rg --type cpp 'getFieldAmount\([^)]+\)\.issue\(\)' -A 2

echo "\nSearching for .getCurrency() calls on getFieldAmount results:"
rg --type cpp 'getFieldAmount\([^)]+\)\.getCurrency\(\)' -A 2

echo "\nSearching for .getIssuer() calls on getFieldAmount results:"
rg --type cpp 'getFieldAmount\([^)]+\)\.getIssuer\(\)' -A 2

echo "\nSearching for explicit casts to STAmount:"
rg --type cpp 'static_cast<STAmount>\(.*getFieldAmount\([^)]+\)\)' -A 2

echo "\nSearching for comparisons with STAmount:"
rg --type cpp 'getFieldAmount\([^)]+\)\s*[=!<>]=\s*STAmount' -A 2

Length of output: 4167

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