Skip to content

Add typed RPC errors for submit-and-wait#328

Open
e-desouza wants to merge 2 commits into
fix/typed-client-network-errorsfrom
fix/typed-rpc-submit-and-wait
Open

Add typed RPC errors for submit-and-wait#328
e-desouza wants to merge 2 commits into
fix/typed-client-network-errorsfrom
fix/typed-rpc-submit-and-wait

Conversation

@e-desouza

Copy link
Copy Markdown
Collaborator

Summary

  • add XRPLRpcError for typed xrpld/Clio RPC error handling
  • add XRPLResponse::rpc_error()
  • use XRPLRpcError::TxnNotFound in submit_and_wait instead of raw string matching
  • add targeted test for the txnNotFound retry branch
  • scope integration coverage away from submit_and_wait implementation details while keeping the branch covered by unit tests

Local validation

  • cargo fmt --all -- --check
  • cargo clippy --all-features -- -D warnings
  • build matrix from Build & Lint workflow
  • cargo test --release
  • cargo test --release --no-default-features --features embassy-rt,core,utils,wallet,models,helpers,websocket,json-rpc
  • unit cargo-llvm-cov thresholds
  • integration cargo-llvm-cov against local xrpld via podman
  • clio smoke: cargo run ... server fee --url http://localhost:51233

Integration patch coverage locally: 100% (no measured integration patch lines after workflow scope).

if let Some(error) = response.error {
if error == "txnNotFound" {
if let Some(error) = response.error.as_ref() {
if response.rpc_error() == Some(XRPLRpcError::TxnNotFound) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think submit_and_wait only cares about txnNotFound error. So, would it be good idea to only list the error codes that we actually use in XRPLRpcError, instead of being exhaustive here? With the current exhaustive list, we would deviate from xrpld implementation as we maintain the copy.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If in future we want to make use of some other error code in source code, we can come here and that specific error code.

## Summary

Adds XLS-0033 Multi-Purpose Token (MPT) support to `xrpl-rust`,
including typed models, binary codec support, request/result handling,
and integration coverage against local `xrpld`/Clio services.

## MPT Support

- Add MPT amount/currency support:
  - `MPTAmount`
  - `MPTCurrency`
  - `Amount::MPTAmount`
  - `Currency::MPTCurrency`
- Add MPT transaction models and validation:
  - `MPTokenIssuanceCreate`
  - `MPTokenIssuanceDestroy`
  - `MPTokenIssuanceSet`
  - `MPTokenAuthorize`
- Add MPT ledger object models:
  - `MPToken`
  - `MPTokenIssuance`
- Add MPT binary codec support for Hash192 / MPTokenIssuanceID and MPT
amounts.
- Add MPT support in transaction parsing / balance conversion helpers.
- Add `account_objects` MPT filters for `mpt_issuance` and `mptoken`.

## Correctness / Review Follow-ups

- Align MPT validation with XLS-0033 and `xrpld` behavior:
  - 63-bit maximum MPT amount handling.
  - strict decimal-string MPT amount validation.
  - strict 48-hex-character MPTokenIssuanceID validation.
  - metadata hex validation and 1024-byte limit.
  - non-zero transfer fee requires `tfMPTCanTransfer`.
- Harden `Amount` and `Currency` deserialization to avoid ambiguous
MPT/issued-currency fallback.
- Replace fragile RPC string checks with typed `XRPLRpcError` mapping
where touched.
- Replace hardcoded branch test literals with named fixtures.
- Preserve `no_std` compatibility for model/helper paths.

## Integration Coverage

Adds end-to-end MPT coverage for:

- Issuance creation with XLS-89-style metadata.
- Holder opt-in / issuer authorization / holder unauthorize lifecycle.
- Issuance destroy success and destroy-with-obligations rejection.
- MPT payments and outstanding amount updates.
- Require-auth rejection before issuer authorization.
- Global lock transfer rejection.
- Maximum amount enforcement.
- Clawback success and clawback permission rejection.
- Holder transfer restriction when `tfMPTCanTransfer` is absent.
- MPT payment binary codec round-trip.

## Validation

Validated locally against Podman `xrpld` / Clio services:

- `cargo fmt --check`
- `git diff --check`
- `cargo test --features integration --lib -- --test-threads=1`
- `cargo test --features integration --test integration_test --
--test-threads=1`
- `cargo test --features integration --test cli_integration --
--test-threads=1`
- `cargo test --no-default-features --features models --lib --
--test-threads=1`
- `cargo test --no-default-features --features
"models,wallet,helpers,json-rpc,embassy-rt" --lib -- --test-threads=1`
- `cargo test --no-default-features --features
"models,wallet,helpers,websocket,embassy-rt" --lib -- --test-threads=1`
- `cargo check --no-default-features --features
"models,wallet,helpers,json-rpc,websocket,embassy-rt"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants