Skip to content

Merge replaceable-collaborators - #46

Merged
AlexanderBuzz merged 3 commits into
masterfrom
replaceable-collaborators
Aug 26, 2026
Merged

Merge replaceable-collaborators#46
AlexanderBuzz merged 3 commits into
masterfrom
replaceable-collaborators

Conversation

@AlexanderBuzz

Copy link
Copy Markdown
Owner

Summary

Two things, both small:

  • JsonRpcClient exposes the objects it works with, so a subclass can replace one. Needed for a Xahau package built on xrpl-php.
  • The README is restructured and three broken code samples are fixed.

Additive throughout — 2.3.0.

Replaceable collaborators

2.1.0 made the definitions injectable, which covers encoding: Xahau assigns different ordinals to most of the types both networks share. It does not cover
behaviour, and Xahau differs there too — it prices a transaction individually, because hooks may fire, so the fee has to be queried per transaction
with the tx_blob rather than derived from the network's base fee.

Tests

Four new tests. Two cover the direct path and would have passed
wiring; the other two cover the indirect paths and fail when the change is
reverted:

  1. testOverriddenAutofillerReachesTheSubmitter
  2. testOverriddenFeeCalculatorReachesTheAutofiller

630 unit tests green, Psalm green. The three Testnet integration tests pass,
including submitAndWait() with an unsigned transaction and a wallet — the path
this PR rewires. examples/mptoken.php runs through with four transactions, all
tesSUCCESS, and the ledger confirms the outcome: MPT balance 600, being 1000
minus the 400 clawed back.

One thing for review

Autofiller::calculateFeePerTransactionType() is public so a subclass can
replace just that method rather than all of autofill(). It was
in the Sugar namespace until 2.2.0 and callable from outside al
exposes nothing new — but if you would rather have it protected
autofiller would override autofill() instead.

JsonRpcClient exposes getAutofiller(), getSubmitter(), getAccountReader(),getOrderbookReader(), getFeeCalculator() and getFaucet(). Overriding one in a subclass substitutes it everywhere the client works with it.

Submitter and Autofiller no longer construct collaborators of their own but ask the client for them, so an override reaches the indirect paths too - notably submitAndWait(), which autofills through the Submitter rather than through the client.

This is needed for a Xahau package built on the upcoming xrpl-php. 3.0.0 made the definitions injectable, which covers the encoding: Xahau assigns different ordinals to most of the types both networks share. It does not cover behaviour, and Xahau differs there as well - it prices a transaction individually because hooks may fire, so its fee has to be queried per transaction with the tx_blob rather than derived from the network's base fee. Submitting a Remit to the Xahau testnet with the XRP Ledger formula is rejected with telINSUF_FEE_P: 12 drops against the 24 the server asks for.

Without this the Xahau package could write its own autofiller but not get it into the normal call path, and $client->submitAndWait($tx, autofill: true) would keep setting the wrong fee.

Additive: every getter has the previous behaviour as its default.
- Docker and the test instructions move out of "Examples", where they were
  subsections, into a "Development" block at the end
- New section "The objects behind the client" for the classes added in 2.2.0,
  which the README did not mention although the Sugar functions are deprecated
  in their favour
- The five examples that were missing from the list are added

Fixes three defects in the code samples:

- The account_objects sample called getBody() on the return of syncRequest(),
  which is a BaseResponse and has no such method, so it died with a fatal error.
  It also carried an "Account Info" heading over an AccountObjectsRequest.
- The payment sample derived the operational wallet from the standby seed.
- It sent 100 XRP, exactly what the faucet hands out, so following it with a
  faucet wallet yields tecUNFUNDED_PAYMENT because reserve and fee are left
  uncovered.

The payment sample now leads with submitAndWait($tx, autofill: true,
wallet: $wallet), which only started working with the getSignedTx() fix in
2.2.0, and keeps the sign-then-submit form as the alternative the files in
examples/ use. All samples were run against the Testnet.
@AlexanderBuzz
AlexanderBuzz merged commit b34c7f8 into master Aug 26, 2026
3 checks passed
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.

1 participant