Merge replaceable-collaborators - #46
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two things, both small:
JsonRpcClientexposes the objects it works with, so a subclass can replace one. Needed for a Xahau package built on xrpl-php.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_blobrather 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:
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.