Repository navigation
feat: propose Custody XRPL transaction orders from an address, and harden the on-chain wait - #63
Merged
Merged
Conversation
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.
High Level Overview of Change
Propose Custody's own XRPL operation from an address.
api.proposetakes a fullv0_CreateTransactionOrderpayload, so callers had to look up the Custody account for an address, generate the order id, and fill in the fee strategy and memos themselves. The newapi.proposeTransactionOrderdoes that:accountin the custodian's domain, withledgerIdto pick one when the address is on several ledgers.Paymentto a CustodyEndpoint. Defaults the order to aPriority: Lowfee, no memos, and no custom properties. The fee strategy, maximum fee, memos, source tag, and custom properties can all be set, and everyapi.proposeenvelope option is accepted.idis the idempotency key. The returnedintentIdis also the order id that the on-chain transaction is filed under.dryRun: truedry-runs the same order before proposing. If Custody says it would fail, it throwsDryRunFailedErrorwith the verdict, and nothing is proposed.propose. ThrowsAccountNotFoundErrorwhen no account in the domain holds the address.CustodyTransactionOrder,CustodyTransactionOrderOptions.Harden the on-chain wait (
client.intent.awaitOnChain,custody.pollTransactionOnChain, and the confirmation step ofsubmitAndWait):Replaced. The wait now ignoresReplacedattempts and follows the newest surviving one byregisteredAt. Before, it read the first listed transaction, so a resubmitted transaction could be reported as dead while its replacement went on to succeed.Failed(e.g. hintInvalidUserPayload) orInterruptednow ends the wait with that reason, instead of polling to the timeout and reporting "still in flight".Supporting changes:
api.tsreached its line limit, so it was split. Its public types move toapi-types.ts(package exports unchanged), and checking a payload against the instance's version becomesVersionGuard.assertPayload.transactionOrderPayload. The existing tests of the native order's exact shape pass unchanged.Context of Change
These came out of mapping a production Custody integration onto simpleXRPL, call by call. Its core flows are MPT issuance creation, MPT payment to a Custody endpoint, and MPT authorize. They were possible through
api.propose, but each repeated the same account lookup and order boilerplate, and the endpoint payment had no higher-level path at all.proposeTransactionOrdermakes each flow a single call. The same review found the on-chain wait could misread a resubmitted transaction, and waited out the full timeout on transactions Custody had already failed.Type of Change
Test Plan
proposeTransactionOrder:idbecomes both ids;dryRun: truedry-runs exactly the order it then proposes;DryRunFailedErrorwith the verdict and proposes nothing;AccountNotFoundErrorfor an unknown sender;Replacedattempt listed first and follows its replacement;FailedandInterrupted, with the hint or cause in the message;proposeTransactionOrderwithdryRun: truefor an MPT payment to a nonexistent endpoint. Custody parses the endpoint destination and fails the dry run ("Endpoint … does not exist"). The call throwsDryRunFailedErrorand nothing is proposed.